342cbb9b1662e340fa16a61e1f86470a2935f50c
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestStringId.php
1 <?php
2
3 namespace Drupal\entity_test\Entity;
4 use Drupal\Core\Field\BaseFieldDefinition;
5 use Drupal\Core\Entity\EntityTypeInterface;
6
7 /**
8  * Defines a test entity class with a string ID.
9  *
10  * @ContentEntityType(
11  *   id = "entity_test_string_id",
12  *   label = @Translation("Test entity with string_id"),
13  *   handlers = {
14  *     "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
15  *     "form" = {
16  *       "default" = "Drupal\entity_test\EntityTestForm"
17  *     },
18  *     "translation" = "Drupal\content_translation\ContentTranslationHandler",
19  *     "route_provider" = {
20  *       "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
21  *     },
22  *   },
23  *   base_table = "entity_test_string",
24  *   admin_permission = "administer entity_test content",
25  *   entity_keys = {
26  *     "id" = "id",
27  *     "uuid" = "uuid",
28  *     "bundle" = "type",
29  *     "label" = "name",
30  *   },
31  *   links = {
32  *     "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}",
33  *     "add-form" = "/entity_test_string_id/add",
34  *     "edit-form" = "/entity_test_string_id/manage/{entity_test_string_id}",
35  *   },
36  *   field_ui_base_route = "entity.entity_test_string_id.admin_form",
37  * )
38  */
39 class EntityTestStringId extends EntityTest {
40
41   /**
42    * {@inheritdoc}
43    */
44   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
45     $fields = parent::baseFieldDefinitions($entity_type);
46     $fields['id'] = BaseFieldDefinition::create('string')
47       ->setLabel(t('ID'))
48       ->setDescription(t('The ID of the test entity.'))
49       ->setReadOnly(TRUE)
50       // In order to work around the InnoDB 191 character limit on utf8mb4
51       // primary keys, we set the character set for the field to ASCII.
52       ->setSetting('is_ascii', TRUE);
53     return $fields;
54   }
55
56 }