class EntityTestWithBundle

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle
  2. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle
  3. 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php \Drupal\entity_test\Entity\EntityTestWithBundle

Defines the Test entity with bundle entity class.

Plugin annotation


@ContentEntityType(
  id = "entity_test_with_bundle",
  label = @Translation("Test entity with bundle"),
  handlers = {
    "list_builder" = "Drupal\entity_test\EntityTestListBuilder",
    "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
    "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
    "form" = {
      "default" = "\Drupal\Core\Entity\ContentEntityForm",
      "delete" = "\Drupal\Core\Entity\EntityDeleteForm"
    },
    "route_provider" = {
      "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
    },
  },
  base_table = "entity_test_with_bundle",
  data_table = "entity_test_with_bundle_field_data",
  admin_permission = "administer entity_test_with_bundle content",
  persistent_cache = FALSE,
  translatable = TRUE,
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid",
    "bundle" = "type",
    "label" = "name",
    "langcode" = "langcode",
  },
  bundle_entity_type = "entity_test_bundle",
  links = {
    "canonical" = "/entity_test_with_bundle/{entity_test_with_bundle}",
    "add-page" = "/entity_test_with_bundle/add",
    "add-form" = "/entity_test_with_bundle/add/{entity_test_bundle}",
    "edit-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/edit",
    "delete-form" = "/entity_test_with_bundle/{entity_test_with_bundle}/delete",
    "create" = "/entity_test_with_bundle",
  },
)

Hierarchy

Expanded class hierarchy of EntityTestWithBundle

6 files declare their use of EntityTestWithBundle
ContentTranslationModuleInstallTest.php in core/modules/content_translation/tests/src/Kernel/ContentTranslationModuleInstallTest.php
EntityAddUITest.php in core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php
EntityBaseTest.php in core/tests/Drupal/KernelTests/Core/Entity/EntityBaseTest.php
EntityBundleConditionTest.php in core/tests/Drupal/KernelTests/Core/Entity/EntityBundleConditionTest.php
EntityBundleListCacheTest.php in core/tests/Drupal/FunctionalTests/Entity/EntityBundleListCacheTest.php

... See full list

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php, line 50

Namespace

Drupal\entity_test\Entity
View source
class EntityTestWithBundle extends ContentEntityBase {
  
  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))
      ->setDescription(t('The name of the test entity.'))
      ->setTranslatable(TRUE)
      ->setSetting('max_length', 32)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'string',
      'weight' => -5,
    ])
      ->setDisplayOptions('form', [
      'type' => 'string_textfield',
      'weight' => -5,
    ]);
    return $fields;
  }

}

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