You are here

public function CommentController::commentApprove in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/comment/src/Controller/CommentController.php \Drupal\comment\Controller\CommentController::commentApprove()
  2. 9 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

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 102

Class

CommentController
Controller for the comment entity.

Namespace

Drupal\comment\Controller

Code

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