function EntityTestUuidId::baseFieldDefinitions

Overrides EntityTest::baseFieldDefinitions

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUuidId.php, line 51

Class

EntityTestUuidId
Defines a test entity class with UUIDs as IDs.

Namespace

Drupal\entity_test\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    // Configure a string field to match the UUID field configuration and use it
    // for both the ID and the UUID key. The UUID field type cannot be used
    // because it would add a unique key to the data table.
    $fields[$entity_type->getKey('uuid')] = BaseFieldDefinition::create('string')->setLabel(new TranslatableMarkup('UUID'))
        ->setSetting('max_length', 128)
        ->setSetting('is_ascii', TRUE)
        ->setDefaultValueCallback(static::class . '::generateUuid');
    return $fields;
}

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