function CommentForm::getStatusMessage

Gets an appropriate status message when a comment is saved.

Parameters

\Drupal\comment\CommentInterface $comment: The comment being saved.

bool $is_new: TRUE if a new comment is created. $comment->isNew() cannot be used here because the comment has already been saved by the time the message is rendered.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup A translatable string containing the appropriate status message.

1 call to CommentForm::getStatusMessage()
CommentForm::save in core/modules/comment/src/CommentForm.php
Form submission handler for the 'save' action.

File

core/modules/comment/src/CommentForm.php, line 431

Class

CommentForm
Base handler for comment forms.

Namespace

Drupal\comment

Code

protected function getStatusMessage(CommentInterface $comment, bool $is_new) : TranslatableMarkup {
    if (!$comment->isPublished() && !$this->currentUser
        ->hasPermission('administer comments')) {
        return $this->t('Your comment has been queued for review by site administrators and will be published after approval.');
    }
    // Check whether the comment is new or not.
    if ($is_new) {
        return $this->t('Your comment has been posted.');
    }
    return $this->t('Your comment has been updated.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.