本文整理汇总了PHP中Drupal\node\NodeInterface::urlInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::urlInfo方法的具体用法?PHP NodeInterface::urlInfo怎么用?PHP NodeInterface::urlInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\node\NodeInterface
的用法示例。
在下文中一共展示了NodeInterface::urlInfo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doPageRdfaTests
/**
* Tests that page data is exposed using RDFa.
*
* Two fields are not tested for output here. Changed date is not displayed
* on the page, so there is no test for output in node view. Comment count is
* displayed in teaser view, so it is tested in the front page tests.
*/
protected function doPageRdfaTests()
{
// The standard profile hides the created date on pages. Revert display to
// true for testing.
// @todo Clean-up standard profile defaults.
$node_type = NodeType::load('page');
$node_type->setDisplaySubmitted(TRUE);
$node_type->save();
// Feed the HTML into the parser.
$graph = $this->getRdfGraph($this->page->urlInfo());
// Type.
$this->assertEqual($graph->type($this->pageUri), 'schema:WebPage', 'Page type was found (schema:WebPage).');
// Test the properties that are common between pages and articles.
$this->assertRdfaCommonNodeProperties($graph, $this->page, "Page");
}
示例2: testBookDelete
/**
* Tests the access for deleting top-level book nodes.
*/
function testBookDelete()
{
$node_storage = $this->container->get('entity.manager')->getStorage('node');
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$edit = array();
// Test access to delete top-level and child book nodes.
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($nodes[4]->id()));
$node4 = $node_storage->load($nodes[4]->id());
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
// Delete all child book nodes and retest top-level node deletion.
foreach ($nodes as $node) {
$nids[] = $node->id();
}
entity_delete_multiple('node', $nids);
$this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
$node_storage->resetCache(array($this->book->id()));
$node = $node_storage->load($this->book->id());
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
// Tests directly deleting a book parent.
$nodes = $this->createBook();
$this->drupalLogin($this->adminUser);
$this->drupalGet($this->book->urlInfo('delete-form'));
$this->assertRaw(t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $this->book->label()]));
// Delete parent, and visit a child page.
$this->drupalPostForm($this->book->urlInfo('delete-form'), [], t('Delete'));
$this->drupalGet($nodes[0]->urlInfo());
$this->assertResponse(200);
$this->assertText($nodes[0]->label());
// The book parents should be updated.
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
$node_storage->resetCache();
$child = $node_storage->load($nodes[0]->id());
$this->assertEqual($child->id(), $child->book['bid'], 'Child node book ID updated when parent is deleted.');
// 3rd-level children should now be 2nd-level.
$second = $node_storage->load($nodes[1]->id());
$this->assertEqual($child->id(), $second->book['bid'], '3rd-level child node is now second level when top-level node is deleted.');
}
示例3: save
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state)
{
$form_state->setRedirect('entity.node.canonical', array('node' => $this->entity->id()));
$book_link = $form_state->getValue('book');
if (!$book_link['bid']) {
drupal_set_message($this->t('No changes were made'));
return;
}
$this->entity->book = $book_link;
if ($this->bookManager->updateOutline($this->entity)) {
if (isset($this->entity->book['parent_mismatch']) && $this->entity->book['parent_mismatch']) {
// This will usually only happen when JS is disabled.
drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.'));
$form_state->setRedirectUrl($this->entity->urlInfo('book-outline-form'));
} else {
drupal_set_message($this->t('The book outline has been updated.'));
}
} else {
drupal_set_message($this->t('There was an error adding the post to the book.'), 'error');
}
}
示例4: buildLinks
/**
* Build the default links (Read more) for a node.
*
* @param \Drupal\node\NodeInterface $entity
* The node object.
* @param string $view_mode
* A view mode identifier.
*
* @return array
* An array that can be processed by drupal_pre_render_links().
*/
protected static function buildLinks(NodeInterface $entity, $view_mode)
{
$links = array();
// Always display a read more link on teasers because we have no way
// to know when a teaser view is different than a full view.
if ($view_mode == 'teaser') {
$node_title_stripped = strip_tags($entity->label());
$links['node-readmore'] = array('title' => t('Read more<span class="visually-hidden"> about @title</span>', array('@title' => $node_title_stripped)), 'url' => $entity->urlInfo(), 'language' => $entity->language(), 'html' => TRUE, 'attributes' => array('rel' => 'tag', 'title' => $node_title_stripped));
}
return array('#theme' => 'links__node__node', '#links' => $links, '#attributes' => array('class' => array('links', 'inline')));
}
示例5: getCancelUrl
/**
* {@inheritdoc}
*/
public function getCancelUrl()
{
return $this->node->urlInfo();
}
示例6: delete
/**
* {@inheritdoc}
*/
public function delete(array $form, FormStateInterface $form_state)
{
$form_state->setRedirectUrl($this->entity->urlInfo('book-remove-form'));
}
示例7: delete
/**
* {@inheritdoc}
*/
public function delete(array $form, array &$form_state)
{
$form_state['redirect_route'] = $this->entity->urlInfo('book-remove-form');
}