function EntityTestStringId::baseFieldDefinitions

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php \Drupal\entity_test\Entity\EntityTestStringId::baseFieldDefinitions()
  2. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php \Drupal\entity_test\Entity\EntityTestStringId::baseFieldDefinitions()
  3. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php \Drupal\entity_test\Entity\EntityTestStringId::baseFieldDefinitions()

Overrides EntityTest::baseFieldDefinitions

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestStringId.php, line 44

Class

EntityTestStringId
Defines a test entity class with a string ID.

Namespace

Drupal\entity_test\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['id'] = BaseFieldDefinition::create('string')->setLabel(t('ID'))
        ->setDescription(t('The ID of the test entity.'))
        ->setReadOnly(TRUE)
        ->setSetting('is_ascii', TRUE);
    return $fields;
}

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