function EntityTestComputedBundleField::baseFieldDefinitions
Same name in other branches
- 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedBundleField.php \Drupal\entity_test\Entity\EntityTestComputedBundleField::baseFieldDefinitions()
Overrides EntityTest::baseFieldDefinitions
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Entity/ EntityTestComputedBundleField.php, line 41
Class
- EntityTestComputedBundleField
- An entity used for testing computed bundle field values.
Namespace
Drupal\entity_test\EntityCode
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.