You are here

public static function Comment::getDefaultStatus in Drupal 8

Same name and namespace in other branches
  1. 9 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 550

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;
}