You are here

public static function Comment::getDefaultStatus in Drupal 9

Same name and namespace in other branches
  1. 8 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;
}