CommentController::commentApprove

public CommentController::commentApprove(CommentInterface $comment)

Publishes the specified comment.

Parameters

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

Return value

\Symfony\Component\HttpFoundation\RedirectResponse

File

core/modules/comment/src/Controller/CommentController.php, line 84

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());
}
doc_Drupal
2016-10-29 08:50:33
Comments
Leave a Comment

Please login to continue.