class EntityTestComputedField
Same name and namespace in other branches
- 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php \Drupal\entity_test\Entity\EntityTestComputedField
An entity used for testing computed field values.
Plugin annotation
@ContentEntityType(
id = "entity_test_computed_field",
label = @Translation("Entity Test computed field"),
base_table = "entity_test_computed_field",
handlers = {
"views_data" = "Drupal\entity_test\EntityTestViewsData"
},
entity_keys = {
"id" = "id",
"uuid" = "uuid",
"label" = "name",
},
admin_permission = "administer entity_test content",
links = {
"canonical" = "/entity_test_computed_field/{entity_test_computed_field}",
},
)
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\EntityTestComputedField 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 EntityTestComputedField
4 files declare their use of EntityTestComputedField
- ComputedFieldTest.php in core/
modules/ views/ tests/ src/ Kernel/ Handler/ ComputedFieldTest.php - EntityFieldTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - EntitySerializationTest.php in core/
modules/ serialization/ tests/ src/ Kernel/ EntitySerializationTest.php - EntityTestComputedFieldTest.php in core/
modules/ jsonapi/ tests/ src/ Functional/ EntityTestComputedFieldTest.php
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestComputedField.php, line 33
Namespace
Drupal\entity_test\EntityView source
class EntityTestComputedField extends EntityTest {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['computed_string_field'] = BaseFieldDefinition::create('string')->setLabel('Computed Field Test')
->setComputed(TRUE)
->setClass(ComputedTestFieldItemList::class);
$fields['computed_reference_field'] = BaseFieldDefinition::create('entity_reference')->setLabel('Computed Reference Field Test')
->setComputed(TRUE)
->setSetting('target_type', 'entity_test')
->setClass(ComputedReferenceTestFieldItemList::class);
$fields['computed_test_cacheable_string_field'] = BaseFieldDefinition::create('computed_test_cacheable_string_item')->setLabel(new TranslatableMarkup('Computed Cacheable String Field Test'))
->setComputed(TRUE)
->setClass(ComputedTestCacheableStringItemList::class)
->setReadOnly(FALSE)
->setInternal(FALSE);
return $fields;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.