Commit cd8986c2 authored by alexpott's avatar alexpott
Browse files

Issue #2278567 by kgoel, azinck, dawehner | Crell: Standardize node route names by relationship.

parent 2d03e83a
......@@ -103,9 +103,9 @@ public function label();
* example:
* @code
* links = {
* "canonical" = "node.view",
* "edit-form" = "node.page_edit",
* "version-history" = "node.revision_overview"
* "canonical" = "entity.node.canonical",
* "edit-form" = "entity.node.edit_form",
* "version-history" = "entity.node.version_history"
* }
* @endcode
* or specified in a callback function set like:
......
......@@ -59,7 +59,7 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state);
* @endcode
* And here is an example of how to redirect to 'node/123?foo=bar#baz':
* @code
* $form_state->setRedirect('node.view',
* $form_state->setRedirect('entity.node.canonical',
* array('node' => 123),
* array(
* 'query' => array(
......
......@@ -29,7 +29,7 @@ function theme_book_admin_table($variables) {
$access = \Drupal::currentUser()->hasPermission('administer nodes');
foreach (Element::children($form) as $key) {
$nid = $form[$key]['nid']['#value'];
$href = \Drupal::url('node.view', array('node' => $nid));
$href = \Drupal::url('entity.node.canonical', array('node' => $nid));
// Add special classes to be used with tabledrag.js.
$form[$key]['pid']['#attributes']['class'] = array('book-pid');
......@@ -50,13 +50,13 @@ function theme_book_admin_table($variables) {
if ($access) {
$links['edit'] = array(
'title' => t('Edit'),
'route_name' => 'node.page_edit',
'route_name' => 'entity.node.edit_form',
'route_parameters' => array('node' => $nid),
'query' => $destination,
);
$links['delete'] = array(
'title' => t('Delete'),
'route_name' => 'node.delete_confirm',
'route_name' => 'entity.node.delete_form',
'route_parameters' => array('node' => $nid),
'query' => $destination,
);
......
......@@ -10,6 +10,6 @@ book.settings:
book.outline:
route_name: book.outline
base_route: node.view
base_route: entity.node.canonical
title: Outline
weight: 2
......@@ -406,7 +406,7 @@ function template_preprocess_book_navigation(&$variables) {
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = $book_link['bid'];
$variables['book_title'] = String::checkPlain($book_link['link_title']);
$variables['book_url'] = \Drupal::url('node.view', array('node' => $book_link['bid']));
$variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid']));
$variables['current_depth'] = $book_link['depth'];
$variables['tree'] = '';
......@@ -419,7 +419,7 @@ function template_preprocess_book_navigation(&$variables) {
$build = array();
if ($prev = $book_outline->prevLink($book_link)) {
$prev_href = \Drupal::url('node.view', array('node' => $prev['nid']));
$prev_href = \Drupal::url('entity.node.canonical', array('node' => $prev['nid']));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'prev',
'href' => $prev_href,
......@@ -431,7 +431,7 @@ function template_preprocess_book_navigation(&$variables) {
/** @var \Drupal\book\BookManagerInterface $book_manager */
$book_manager = \Drupal::service('book.manager');
if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) {
$parent_href = \Drupal::url('node.view', array('node' => $book_link['pid']));
$parent_href = \Drupal::url('entity.node.canonical', array('node' => $book_link['pid']));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'up',
'href' => $parent_href,
......@@ -441,7 +441,7 @@ function template_preprocess_book_navigation(&$variables) {
}
if ($next = $book_outline->nextLink($book_link)) {
$next_href = \Drupal::url('node.view', array('node' => $next['nid']));
$next_href = \Drupal::url('entity.node.canonical', array('node' => $next['nid']));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'next',
'href' => $next_href,
......
......@@ -87,7 +87,7 @@ public function build(RouteMatchInterface $route_match) {
while (!empty($book['p' . ($depth + 1)])) {
if (!empty($parent_books[$book['p' . $depth]]) && ($parent_book = $parent_books[$book['p' . $depth]])) {
if ($parent_book->access('view', $this->account)) {
$links[] = $this->l($parent_book->label(), 'node.view', array('node' => $parent_book->id()));
$links[] = $this->l($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
}
}
$depth++;
......
......@@ -103,7 +103,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
*/
public function submit(array $form, FormStateInterface $form_state) {
$form_state->setRedirect(
'node.view',
'entity.node.canonical',
array('node' => $this->entity->id())
);
$book_link = $form_state->getValue('book');
......
......@@ -53,7 +53,7 @@ public function getBookAdminRoutes() {
*/
public function testBookNodeLocalTasks($route) {
$this->assertLocalTasks($route, array(
0 => array('book.outline', 'node.view', 'node.page_edit', 'node.delete_confirm', 'node.revision_overview',),
0 => array('book.outline', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',),
));
}
......@@ -62,7 +62,7 @@ public function testBookNodeLocalTasks($route) {
*/
public function getBookNodeRoutes() {
return array(
array('node.view'),
array('entity.node.canonical'),
array('book.outline'),
);
}
......
......@@ -27,7 +27,7 @@ public function setUp() {
$entity_type->expects($this->any())
->method('getLinkTemplate')
->will($this->returnValueMap(array(
array('canonical', 'node.view'),
array('canonical', 'entity.node.canonical'),
array('drupal:content-translation-overview', 'content_translation.translation_overview_node'),
)));
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
......@@ -53,19 +53,19 @@ public function testBlockAdminDisplay($route, $expected) {
*/
public function providerTestBlockAdminDisplay() {
return array(
array('node.view', array(array(
array('entity.node.canonical', array(array(
'content_translation.local_tasks:content_translation.translation_overview_node',
'node.view',
'node.page_edit',
'node.delete_confirm',
'node.revision_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
))),
array('content_translation.translation_overview_node', array(array(
'content_translation.local_tasks:content_translation.translation_overview_node',
'node.view',
'node.page_edit',
'node.delete_confirm',
'node.revision_overview',
'entity.node.canonical',
'entity.node.edit_form',
'entity.node.delete_form',
'entity.node.version_history',
))),
);
}
......
......@@ -74,9 +74,9 @@ function testDifferentPermissions() {
$response = $this->renderContextualLinks($ids, 'node');
$this->assertResponse(200);
$json = Json::decode($response);
$this->assertIdentical($json[$ids[0]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/1/edit">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[0]], '<ul class="contextual-links"><li class="entitynodeedit-form"><a href="' . base_path() . 'node/1/edit">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[1]], '');
$this->assertIdentical($json[$ids[2]], '<ul class="contextual-links"><li class="nodepage-edit"><a href="' . base_path() . 'node/3/edit">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[2]], '<ul class="contextual-links"><li class="entitynodeedit-form"><a href="' . base_path() . 'node/3/edit">Edit</a></li></ul>');
$this->assertIdentical($json[$ids[3]], '');
// Authenticated user: can access contextual links, cannot edit articles.
......
......@@ -18,7 +18,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return $route_match->getRouteName() == 'node.view'
return $route_match->getRouteName() == 'entity.node.canonical'
&& $route_match->getParameter('node')
&& $this->forumManager->checkNodeType($route_match->getParameter('node'));
}
......
......@@ -84,20 +84,20 @@ public function providerTestApplies() {
),
array(
FALSE,
'NOT.node.view',
'NOT.entity.node.canonical',
),
array(
FALSE,
'node.view',
'entity.node.canonical',
),
array(
FALSE,
'node.view',
'entity.node.canonical',
array(array('node', NULL)),
),
array(
TRUE,
'node.view',
'entity.node.canonical',
array(array('node', $mock_node)),
),
);
......
......@@ -48,8 +48,8 @@ public function getRouteParameters();
*
* @param array $route_parameters
* The route parameters, usually derived from the path entered by the
* administrator. For example, for a link to a node with route 'node.view'
* the route needs the node ID as a parameter:
* administrator. For example, for a link to a node with route
* 'entity.node.canonical' the route needs the node ID as a parameter:
* @code
* array('node' => 2)
* @endcode
......
......@@ -209,7 +209,7 @@ function menu_ui_node_save(EntityInterface $node) {
$entity = entity_create('menu_link_content', array(
'title' => trim($definition['title']),
'description' => trim($definition['description']),
'route_name' => 'node.view',
'route_name' => 'entity.node.canonical',
'route_parameters' => array('node' => $node->id()),
'menu_name' => $definition['menu_name'],
'parent' => $definition['parent'],
......@@ -233,7 +233,7 @@ function menu_ui_node_predelete(EntityInterface $node) {
// Delete all MenuLinkContent links that point to this node.
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$result = $menu_link_manager->loadLinksByRoute('node.view', array('node' => $node->id()));
$result = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node->id()));
if (!empty($result)) {
foreach ($result as $id => $instance) {
......@@ -259,7 +259,7 @@ function menu_ui_node_prepare_form(NodeInterface $node, $operation, FormStateInt
$type_menus = $node_type_config->get('available_menus');
if (in_array($menu_name, $type_menus)) {
$query = \Drupal::entityQuery('menu_link_content')
->condition('route_name', 'node.view')
->condition('route_name', 'entity.node.canonical')
->condition('route_parameters', serialize(array('node' => $node->id())))
->condition('menu_name', $menu_name)
->sort('id', 'ASC')
......@@ -271,7 +271,7 @@ function menu_ui_node_prepare_form(NodeInterface $node, $operation, FormStateInt
// Check all allowed menus if a link does not exist in the default menu.
if (!$id && !empty($type_menus)) {
$query = \Drupal::entityQuery('menu_link_content')
->condition('route_name', 'node.view')
->condition('route_name', 'entity.node.canonical')
->condition('route_parameters', serialize(array('node' => $node->id())))
->condition('menu_name', array_values($type_menus), 'IN')
->sort('id', 'ASC')
......
......@@ -126,7 +126,7 @@ function testMenuNodeFormWidget() {
// Add a menu link to the Administration menu.
$item = entity_create('menu_link_content', array(
'route_name' => 'node.view',
'route_name' => 'entity.node.canonical',
'route_parameters' => array('node' => $node->id()),
'title' => $this->randomMachineName(16),
'menu_name' => 'admin',
......@@ -150,7 +150,7 @@ function testMenuNodeFormWidget() {
$child_node = $this->drupalCreateNode(array('type' => 'article'));
// Assign a menu link to the second node, being a child of the first one.
$child_item = entity_create('menu_link_content', array(
'route_name' => 'node.view',
'route_name' => 'entity.node.canonical',
'route_parameters' => array('node' => $child_node->id()),
'title' => $this->randomMachineName(16),
'parent' => $item->getPluginId(),
......
......@@ -318,7 +318,7 @@ function doMenuTests() {
$this->assertMenuLink($item6->getPluginId(), array(
'children' => array(),
'parents' => array($item6->getPluginId(), $item4->getPluginId()),
'route_name' => 'node.view',
'route_name' => 'entity.node.canonical',
'route_parameters' => array('node' => $node5->id()),
'url' => '',
// See above.
......
node.page_edit:
route_name: node.page_edit
entity.node.edit_form:
route_name: entity.node.edit_form
group: node
title: Edit
node.delete_confirm:
route_name: node.delete_confirm
entity.node.delete_form:
route_name: entity.node.delete_form
group: node
title: Delete
weight: 10
node.view:
route_name: node.view
base_route: node.view
entity.node.canonical:
route_name: entity.node.canonical
base_route: entity.node.canonical
title: 'View'
node.page_edit:
route_name: node.page_edit
base_route: node.view
entity.node.edit_form:
route_name: entity.node.edit_form
base_route: entity.node.canonical
title: Edit
node.delete_confirm:
route_name: node.delete_confirm
base_route: node.view
entity.node.delete_form:
route_name: entity.node.delete_form
base_route: entity.node.canonical
title: Delete
weight: 10
node.revision_overview:
route_name: node.revision_overview
base_route: node.view
entity.node.version_history:
route_name: entity.node.version_history
base_route: entity.node.canonical
title: 'Revisions'
weight: 20
node.type_edit:
entity.node_type.edit_form:
title: 'Edit'
route_name: node.type_edit
base_route: node.type_edit
route_name: entity.node_type.edit_form
base_route: entity.node_type.edit_form
node.overview_types:
title: List
route_name: node.overview_types
......
......@@ -138,10 +138,10 @@ function node_help($route_name, RouteMatchInterface $route_match) {
return '<p>' . t('Content items can be displayed using different view modes: Teaser, Full content, Print, RSS, etc. <em>Teaser</em> is a short format that is typically used in lists of multiple content items. <em>Full content</em> is typically used when the content is displayed on its own page.') . '</p>' .
'<p>' . t('Here, you can define which fields are shown and hidden when %type content is displayed in each view mode, and define how the fields are displayed in each view mode.', array('%type' => $type->label())) . '</p>';
case 'node.revision_overview':
case 'entity.node.version_history':
return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '</p>';
case 'node.page_edit':
case 'entity.node.edit_form':
$node = $route_match->getParameter('node');
$type = $node->getType();
return (!empty($type->help) ? Xss::filterAdmin($type->help) : '');
......@@ -545,7 +545,7 @@ function node_revision_delete($revision_id) {
*/
function node_is_page(NodeInterface $node) {
$route_match = \Drupal::routeMatch();
if ($route_match->getRouteName() == 'node.view') {
if ($route_match->getRouteName() == 'entity.node.canonical') {
$page_node = $route_match->getParameter('node');
}
return (!empty($page_node) ? $page_node->id() == $node->id() : FALSE);
......
......@@ -6,7 +6,7 @@ node.multiple_delete_confirm:
requirements:
_permission: 'administer nodes'
node.page_edit:
entity.node.edit_form:
path: '/node/{node}/edit'
defaults:
_entity_form: 'node.edit'
......@@ -37,7 +37,7 @@ node.add:
options:
_node_operation_route: TRUE
node.view:
entity.node.canonical:
path: '/node/{node}'
defaults:
_content: '\Drupal\node\Controller\NodeViewController::view'
......@@ -45,7 +45,7 @@ node.view:
requirements:
_entity_access: 'node.view'
node.delete_confirm:
entity.node.delete_form:
path: '/node/{node}/delete'
defaults:
_entity_form: 'node.delete'
......@@ -55,7 +55,7 @@ node.delete_confirm:
options:
_node_operation_route: TRUE
node.revision_overview:
entity.node.version_history:
path: '/node/{node}/revisions'
defaults:
_title: 'Revisions'
......@@ -110,14 +110,14 @@ node.type_add:
requirements:
_permission: 'administer content types'
node.type_edit:
entity.node_type.edit_form:
path: '/admin/structure/types/manage/{node_type}'
defaults:
_entity_form: 'node_type.edit'
requirements:
_permission: 'administer content types'
node.type_delete_confirm:
entity.node_type.delete_form:
path: '/admin/structure/types/manage/{node_type}/delete'
defaults:
_entity_form: 'node_type.delete'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment