class EntityTestBaseFieldDisplay
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestBaseFieldDisplay.php \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay
Defines a test entity class for base fields display.
Plugin annotation
@ContentEntityType(
id = "entity_test_base_field_display",
label = @Translation("Test entity - base field display"),
handlers = {
"access" = "Drupal\entity_test\EntityTestAccessControlHandler",
"form" = {
"default" = "Drupal\entity_test\EntityTestForm"
},
"route_provider" = {
"html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
},
},
base_table = "entity_test_base_field_display",
admin_permission = "administer entity_test content",
entity_keys = {
"id" = "id",
"label" = "name",
"uuid" = "uuid",
"bundle" = "type",
"langcode" = "langcode",
},
links = {
"canonical" = "/entity_test_base_field_display/{entity_test_base_field_display}/edit",
"add-form" = "/entity_test_base_field_display/add",
"edit-form" = "/entity_test_base_field_display/manage/{entity_test_base_field_display}",
"delete-form" = "/entity_test/delete/entity_test_base_field_display/{entity_test_base_field_display}/edit",
},
field_ui_base_route = "entity.entity_test_base_field_display.admin_form",
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase extends \Drupal\Core\Entity\EntityInterface uses \Drupal\Core\Cache\RefinableCacheableDependencyTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Entity\ContentEntityBase extends \Drupal\Core\Entity\IteratorAggregate, \Drupal\Core\Entity\ContentEntityInterface, \Drupal\Core\TypedData\TranslationStatusInterface uses \Drupal\Core\Entity\EntityChangesDetectionTrait, \Drupal\Core\Entity\SynchronizableEntityTrait implements \Drupal\Core\Entity\EntityBase
- class \Drupal\entity_test\Entity\EntityTest extends \Drupal\user\EntityOwnerInterface implements \Drupal\Core\Entity\ContentEntityBase
- class \Drupal\entity_test\Entity\EntityTestBaseFieldDisplay implements \Drupal\entity_test\Entity\EntityTest
- class \Drupal\entity_test\Entity\EntityTest extends \Drupal\user\EntityOwnerInterface implements \Drupal\Core\Entity\ContentEntityBase
- class \Drupal\Core\Entity\ContentEntityBase extends \Drupal\Core\Entity\IteratorAggregate, \Drupal\Core\Entity\ContentEntityInterface, \Drupal\Core\TypedData\TranslationStatusInterface uses \Drupal\Core\Entity\EntityChangesDetectionTrait, \Drupal\Core\Entity\SynchronizableEntityTrait implements \Drupal\Core\Entity\EntityBase
Expanded class hierarchy of EntityTestBaseFieldDisplay
2 files declare their use of EntityTestBaseFieldDisplay
- FormTest.php in core/
modules/ field/ tests/ src/ Functional/ FormTest.php - LayoutSectionItemListTest.php in core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutSectionItemListTest.php
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestBaseFieldDisplay.php, line 42
Namespace
Drupal\entity_test\EntityView source
class EntityTestBaseFieldDisplay extends EntityTest {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['test_no_display'] = BaseFieldDefinition::create('text')->setLabel(t('Field with no display'));
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with configurable display'))
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 10,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 10,
])
->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with non-configurable display'))
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 11,
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 11,
]);
$fields['test_display_multiple'] = BaseFieldDefinition::create('text')->setLabel(t('A field with multiple values'))
->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 12,
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 12,
]);
return $fields;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.