diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8742417..59c5553 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -220,10 +220,7 @@ function comment_menu() { ); $items['comment/%comment'] = array( 'title' => 'Comment permalink', - 'page callback' => 'comment_permalink', - 'page arguments' => array(1), - 'access callback' => 'entity_page_access', - 'access arguments' => array(1, 'view'), + 'route_name' => 'comment_permalink', ); $items['comment/%comment/view'] = array( 'title' => 'View comment', @@ -407,39 +404,6 @@ function comment_permission() { } /** - * Redirects comment links to the correct page depending on comment settings. - * - * Since comments are paged there is no way to guarantee which page a comment - * appears on. Comment paging and threading settings may be changed at any time. - * With threaded comments, an individual comment may move between pages as - * comments can be added either before or after it in the overall discussion. - * Therefore we use a central routing function for comment links, which - * calculates the page number based on current comment settings and returns - * the full comment view with the pager set dynamically. - * - * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment - * A comment entity. - * - * @return - * The comment listing set to the page on which the comment appears. - */ -function comment_permalink(Comment $comment) { - if ($node = $comment->nid->entity) { - // Find the current display page for this comment. - $page = comment_get_display_page($comment->id(), $node->type); - - // @todo: Cleaner sub request handling. - $request = drupal_container()->get('request'); - $subrequest = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all()); - $subrequest->query->set('page', $page); - // @todo: Convert the pager to use the request object. - $_GET['page'] = $page; - return drupal_container()->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST); - } - throw new NotFoundHttpException(); -} - -/** * Finds the most recent comments that are available to the current user. * * @param integer $number diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 584d9b0..3265cfd 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Controller; -use Drupal\Core\ControllerInterface; +use Drupal\Core\Controller\ControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\comment\Plugin\Core\Entity\Comment; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -21,7 +21,9 @@ class CommentController implements ControllerInterface { /** - * @var Symfony\Component\HttpKernel\HttpKernelInterface + * The HTTP kernel. + * + * @var \Symfony\Component\HttpKernel\HttpKernelInterface */ protected $httpKernel; @@ -33,9 +35,9 @@ public static function create(ContainerInterface $container) { } /** - * Contructs a new CommentController instance + * Constructs a new CommentController instance * - * @param Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel + * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel * HTTP kernel to handle requests. */ public function __construct(HttpKernelInterface $httpKernel) { @@ -53,10 +55,14 @@ public function __construct(HttpKernelInterface $httpKernel) { * which calculates the page number based on current comment settings and * returns the full comment view with the pager set dynamically. * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request of the page. * @param \Drupal\comment\Plugin\Core\Entity\Comment $comment * A comment entity. * - * @return Symfony\Component\HttpFoundation\Response + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * @return \Symfony\Component\HttpFoundation\Response * The comment listing set to the page on which the comment appears. */ public function commentPermalink(Request $request, Comment $comment) {