diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index ddc6048..eaaeba4 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -1,14 +1,14 @@ comment_edit_page: - pattern: 'comment/{comment}/edit' + pattern: '/comment/{comment}/edit' defaults: - _entity_form: comment.default + _entity_form: 'comment.default' requirements: - _entity_access: comment.update + _entity_access: 'comment.update' comment_approve: - pattern: 'comment/{comment}/approve' + pattern: '/comment/{comment}/approve' defaults: _content: '\Drupal\comment\Controller\CommentController::commentApprove' entity_type: 'comment' requirements: - _entity_access: comment.approve + _entity_access: 'comment.approve' diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index a02b05b..b89b229 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -23,16 +23,16 @@ class CommentController implements ControllerInterface { /** - * {@inheritdoc} + * Constructs a CommentController object. */ - public static function create(ContainerInterface $container) { - return new static(); + public function __construct() { } /** - * Constructs a CommentController object. + * {@inheritdoc} */ - public function __construct() { + public static function create(ContainerInterface $container) { + return new static(); } /** @@ -46,11 +46,11 @@ public function __construct() { * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * @return \Symfony\Component\HttpFoundation\RedirectResponse. */ - function commentApprove(Request $request, CommentInterface $comment) { + public function commentApprove(Request $request, CommentInterface $comment) { // @todo CRSF tokens are validated in the content controller until it gets - // moved to the access layer: - // Integrate CSRF link token directly into routing system: - // https://drupal.org/node/1798296. + // moved to the access layer: + // Integrate CSRF link token directly into routing system: + // https://drupal.org/node/1798296. $token = $request->query->get('token'); if (!isset($token) || !drupal_valid_token($token, 'comment/' . $comment->id() . '/approve')) { throw new AccessDeniedHttpException(); @@ -60,7 +60,8 @@ function commentApprove(Request $request, CommentInterface $comment) { $comment->save(); drupal_set_message(t('Comment approved.')); - return new RedirectResponse(url('node/' . $comment->nid->target_id, array('absolute' => TRUE))); + $permalink_uri = $comment->permalink(); + return new RedirectResponse($permalink_uri['path'], array('absolute' => TRUE)); } }