diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php b/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php new file mode 100644 index 0000000..0142e2c --- /dev/null +++ b/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php @@ -0,0 +1,57 @@ +label()); + $uri = $node->uri(); + // Set the node path as the canonical URL to prevent duplicate content. + drupal_add_html_head_link(array( + 'rel' => 'canonical', + 'href' => url($uri['path'], $uri['options']) + ), TRUE); + // Set the non-aliased path as a default shortlink. + drupal_add_html_head_link(array( + 'rel' => 'shortlink', + 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE))) + ), TRUE); + + return node_show($node); + } + +} diff --git a/core/modules/node/node.module b/core/modules/node/node.module index fbdf07d..fb29bc1 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1634,14 +1634,7 @@ function node_menu() { 'file' => 'node.pages.inc', ); $items['node/%node'] = array( - 'title callback' => 'node_page_title', - 'title arguments' => array(1), - // The page callback also invokes drupal_set_title() in case - // the menu router's title is overridden by a menu link. - 'page callback' => 'node_page_view', - 'page arguments' => array(1), - 'access callback' => 'node_access', - 'access arguments' => array('view', 1), + 'route_name' => 'node_view', ); $items['node/%node/view'] = array( 'title' => 'View', @@ -1732,21 +1725,6 @@ function node_type_page_title($type) { } /** - * Title callback: Displays the node's title. - * - * @param \Drupal\Core\Entity\EntityInterface $node - * The node entity. - * - * @return - * An unsanitized string that is the title of the node. - * - * @see node_menu() - */ -function node_page_title(EntityInterface $node) { - return $node->label(); -} - -/** * Finds the last time a node was changed. * * @param $nid @@ -2111,37 +2089,6 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { } /** - * Page callback: Displays a single node. - * - * @param \Drupal\Core\Entity\EntityInterface $node - * The node entity. - * - * @return - * A page array suitable for use by drupal_render(). - * - * @see node_menu() - */ -function node_page_view(EntityInterface $node) { - // If there is a menu link to this node, the link becomes the last part - // of the active trail, and the link name becomes the page title. - // Thus, we must explicitly set the page title to be the node title. - drupal_set_title($node->label()); - - foreach ($node->uriRelationships() as $rel) { - $uri = $node->uri($rel); - // Set the node path as the canonical URL to prevent duplicate content. - drupal_add_html_head_link(array('rel' => $rel, 'href' => url($uri['path'], $uri['options'])), TRUE); - - if ($rel == 'canonical') { - // Set the non-aliased canonical path as a default shortlink. - drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE); - } - } - - return node_show($node); -} - -/** * Implements hook_update_index(). */ function node_update_index() { diff --git a/core/modules/node/node.routing.yml b/core/modules/node/node.routing.yml index ce897f5..115113d 100644 --- a/core/modules/node/node.routing.yml +++ b/core/modules/node/node.routing.yml @@ -10,3 +10,11 @@ node_page_edit: _entity_form: 'node.edit' requirements: _entity_access: 'node.update' +node_view: + pattern: '/node/{node}' + defaults: + _content: '\Drupal\node\Controller\NodeViewController::render' + node: '' + requirements: + _entity_access: 'node.view' + node: \d+