Newer
Older
<?php
/**
* @file
* Contains \Drupal\entity_test\Entity\EntityTestStringId.
*/
namespace Drupal\entity_test\Entity;
use Drupal\Core\Field\FieldDefinition;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines a test entity class with a string ID.
*
* @ContentEntityType(
* id = "entity_test_string_id",
* label = @Translation("Test entity with string_id"),
* controllers = {
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
* "form" = {
* "default" = "Drupal\entity_test\EntityTestForm"
* },
* "translation" = "Drupal\content_translation\ContentTranslationHandler"
* },
* base_table = "entity_test_string",
* fieldable = TRUE,
* field_cache = TRUE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type"
* },
* links = {
* "canonical" = "entity_test.render",
* "edit-form" = "entity_test.edit_entity_test_string_id",
* "admin-form" = "entity_test.admin_entity_test_string_id"
* }
* )
*/
class EntityTestStringId extends EntityTest {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = FieldDefinition::create('string')
->setLabel(t('ID'))
->setDescription(t('The ID of the test entity.'))
->setReadOnly(TRUE);
return $fields;
}
}