function EntityTestComputedField::baseFieldDefinitions

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php \Drupal\entity_test\Entity\EntityTestComputedField::baseFieldDefinitions()
  2. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php \Drupal\entity_test\Entity\EntityTestComputedField::baseFieldDefinitions()
  3. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php \Drupal\entity_test\Entity\EntityTestComputedField::baseFieldDefinitions()

Overrides EntityTest::baseFieldDefinitions

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php, line 35

Class

EntityTestComputedField
An entity used for testing computed field values.

Namespace

Drupal\entity_test\Entity

Code

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);
    return $fields;
}

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