diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index b89b229..7189584 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -10,6 +10,7 @@ use Drupal\comment\CommentInterface; use Drupal\comment\Plugin\Core\Entity\Comment; use Drupal\Core\Controller\ControllerInterface; +use Drupal\Core\Routing\PathBasedGeneratorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -23,16 +24,26 @@ class CommentController implements ControllerInterface { /** + * The url generator service. + * + * @var \Drupal\Core\Routing\PathBasedGeneratorInterface + */ + protected $urlGenerator; + + /** * Constructs a CommentController object. + * + * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator + * The url generator service. */ - public function __construct() { + public function __construct(PathBasedGeneratorInterface $url_generator) { + $this->urlGenerator = $url_generator; } - /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static(); + return new static(\Drupal::urlGenerator()); } /** @@ -61,7 +72,9 @@ public function commentApprove(Request $request, CommentInterface $comment) { drupal_set_message(t('Comment approved.')); $permalink_uri = $comment->permalink(); - return new RedirectResponse($permalink_uri['path'], array('absolute' => TRUE)); + $permalink_uri['options']['absolute'] = TRUE; + $url = $this->urlGenerator->generateFromPath($permalink_uri['path'], $permalink_uri['options']); + return new RedirectResponse($url); } }