3 namespace Drupal\entity_test\Entity;
5 use Drupal\Core\Entity\ContentEntityBase;
6 use Drupal\Core\Entity\EntityTypeInterface;
7 use Drupal\Core\Field\BaseFieldDefinition;
10 * Defines the Test entity with bundle entity class.
13 * id = "entity_test_with_bundle",
14 * label = @Translation("Test entity with bundle"),
16 * "list_builder" = "Drupal\entity_test\EntityTestListBuilder",
17 * "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
18 * "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
20 * "default" = "\Drupal\Core\Entity\ContentEntityForm",
21 * "delete" = "\Drupal\Core\Entity\EntityDeleteForm"
23 * "route_provider" = {
24 * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
27 * base_table = "entity_test_with_bundle",
28 * admin_permission = "administer entity_test_with_bundle content",
29 * persistent_cache = FALSE,
35 * "langcode" = "langcode",
37 * bundle_entity_type = "entity_test_bundle",
39 * "canonical" = "/entity_test_with_bundle/{entity_test_with_bundle}",
40 * "add-page" = "/entity_test_with_bundle/add",
41 * "add-form" = "/entity_test_with_bundle/add/{entity_test_bundle}",
42 * "edit-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/edit",
43 * "delete-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/delete",
44 * "create" = "/entity_test_with_bundle",
48 class EntityTestWithBundle extends ContentEntityBase {
53 public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
54 $fields = parent::baseFieldDefinitions($entity_type);
56 $fields['name'] = BaseFieldDefinition::create('string')
58 ->setDescription(t('The name of the test entity.'))
59 ->setTranslatable(TRUE)
60 ->setSetting('max_length', 32)
61 ->setDisplayOptions('view', [
66 ->setDisplayOptions('form', [
67 'type' => 'string_textfield',