You are here

public function CommentController::commentApprove in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/comment/src/Controller/CommentController.php \Drupal\comment\Controller\CommentController::commentApprove()

Publishes the specified comment.

Parameters

\Drupal\comment\CommentInterface $comment: A comment entity.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse. Redirects to the permalink URL for this comment.

1 string reference to 'CommentController::commentApprove'
comment.routing.yml in core/modules/comment/comment.routing.yml
core/modules/comment/comment.routing.yml

File

core/modules/comment/src/Controller/CommentController.php, line 90
Contains \Drupal\comment\Controller\CommentController.

Class

CommentController
Controller for the comment entity.

Namespace

Drupal\comment\Controller

Code

public function commentApprove(CommentInterface $comment) {
  $comment
    ->setPublished(TRUE);
  $comment
    ->save();
  drupal_set_message($this
    ->t('Comment approved.'));
  $permalink_uri = $comment
    ->permalink();
  $permalink_uri
    ->setAbsolute();
  return new RedirectResponse($permalink_uri
    ->toString());
}