function CommentTestBaseField::baseFieldDefinitions

Same name in other branches
  1. 9 core/modules/comment/tests/modules/comment_base_field_test/src/Entity/CommentTestBaseField.php \Drupal\comment_base_field_test\Entity\CommentTestBaseField::baseFieldDefinitions()
  2. 10 core/modules/comment/tests/modules/comment_base_field_test/src/Entity/CommentTestBaseField.php \Drupal\comment_base_field_test\Entity\CommentTestBaseField::baseFieldDefinitions()
  3. 11.x core/modules/comment/tests/modules/comment_base_field_test/src/Entity/CommentTestBaseField.php \Drupal\comment_base_field_test\Entity\CommentTestBaseField::baseFieldDefinitions()

Overrides EntityTest::baseFieldDefinitions

File

core/modules/comment/tests/modules/comment_base_field_test/src/Entity/CommentTestBaseField.php, line 26

Class

CommentTestBaseField
Defines a test entity class for comment as a base field.

Namespace

Drupal\comment_base_field_test\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['test_comment'] = BaseFieldDefinition::create('comment')->setLabel(t('A comment field'))
        ->setSetting('comment_type', 'test_comment_type')
        ->setDefaultValue([
        'status' => CommentItemInterface::OPEN,
    ]);
    return $fields;
}

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