function Comment::getDefaultStatus

Same name in other branches
  1. 9 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getDefaultStatus()
  2. 8.9.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getDefaultStatus()
  3. 11.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment::getDefaultStatus()

Default value callback for 'status' base field definition.

Return value

bool TRUE if the comment should be published, FALSE otherwise.

See also

::baseFieldDefinitions()

File

core/modules/comment/src/Entity/Comment.php, line 542

Class

Comment
Defines the comment entity class.

Namespace

Drupal\comment\Entity

Code

public static function getDefaultStatus() {
    return \Drupal::currentUser()->hasPermission('skip comment approval') ? CommentInterface::PUBLISHED : CommentInterface::NOT_PUBLISHED;
}

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