Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

function 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 552

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal