3 namespace Drupal\entity_test\Entity;
4 use Drupal\Core\Field\BaseFieldDefinition;
5 use Drupal\Core\Entity\EntityTypeInterface;
8 * Defines a test entity class with a string ID.
11 * id = "entity_test_string_id",
12 * label = @Translation("Test entity with string_id"),
14 * "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
16 * "default" = "Drupal\entity_test\EntityTestForm"
18 * "translation" = "Drupal\content_translation\ContentTranslationHandler",
19 * "route_provider" = {
20 * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
23 * base_table = "entity_test_string",
24 * admin_permission = "administer entity_test content",
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}",
36 * field_ui_base_route = "entity.entity_test_string_id.admin_form",
39 class EntityTestStringId extends EntityTest {
44 public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
45 $fields = parent::baseFieldDefinitions($entity_type);
46 $fields['id'] = BaseFieldDefinition::create('string')
48 ->setDescription(t('The ID of the test entity.'))
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);