diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index b41243d..68f6874 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -256,6 +256,10 @@ function comment_menu() { 'file' => 'comment.admin.inc', 'weight' => 20, ); + $items['comment/reply/%node'] = array( + 'title' => 'Add new comment', + 'route_name' => 'comment_reply', + ); return $items; } diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index e816760..0b52294 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -6,8 +6,9 @@ comment_edit_page: _entity_access: comment.update comment_reply: - pattern: 'comment/reply/{node}' + pattern: 'comment/reply/{node}/{pid}' defaults: _content: '\Drupal\comment\Controller\CommentController::getReply' + pid : ~ requirements: _entity_access: node.view diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentPageController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php similarity index 93% rename from core/modules/comment/lib/Drupal/comment/Controller/CommentPageController.php rename to core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 19fc4ad..7103a1e 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentPageController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\comment\Controller\CommentPageController. + * Contains \Drupal\comment\Controller\CommentController. */ namespace Drupal\comment\Controller; @@ -10,13 +10,15 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Routing\PathBasedGeneratorInterface; +use Drupal\Node\NodeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; /** * Controller for comment forms. */ -class CommentPageController implements ControllerInterface { +class CommentController implements ControllerInterface { /** * The entity manager service. @@ -66,21 +68,21 @@ public static function create(ContainerInterface $container) { * * @param \Drupal\node\NodeInterface $node * Every comment belongs to a node. This is that node. - * @param $pid + * @param int $pid * (optional) Some comments are replies to other comments. In those cases, * $pid is the parent comment's comment ID. Defaults to NULL. * * @param \Symfony\Component\HttpFoundation\Request $request * The current request object containing the search string. * - * @return array + * @return array|Symfony\Component\HttpFoundation\RedirectResponse * An associative array containing: * - An array for rendering the node or parent comment. * - comment_node: If the comment is a reply to the node. * - comment_parent: If the comment is a reply to another comment. * - comment_form: The comment form as a renderable array. */ - function getReply(NodeInterface $node, $pid, Request $request) { + public function getReply(NodeInterface $node, $pid, Request $request) { // Set the breadcrumb trail. drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->label(), 'node/' . $node->id()))); $op = $request->request->get('op'); @@ -107,7 +109,7 @@ function getReply(NodeInterface $node, $pid, Request $request) { if ($pid) { if (user_access('access comments')) { // Load the parent comment. - $comments = $this->entityManager->getStorageController('comment')->load($pid); + $comments = $this->entityManager->getStorageController('comment')->load(array($pid)); $comment = reset($comments); if ($comment->status->value == COMMENT_PUBLISHED) { // If that comment exists, make sure that the current comment and the