function EntityTestFieldOverride::bundleFieldDefinitions

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php \Drupal\entity_test\Entity\EntityTestFieldOverride::bundleFieldDefinitions()
  2. 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php \Drupal\entity_test\Entity\EntityTestFieldOverride::bundleFieldDefinitions()
  3. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php \Drupal\entity_test\Entity\EntityTestFieldOverride::bundleFieldDefinitions()

Overrides ContentEntityBase::bundleFieldDefinitions

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestFieldOverride.php, line 37

Class

EntityTestFieldOverride
Defines a test entity class for testing default values.

Namespace

Drupal\entity_test\Entity

Code

public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
    $fields = parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions);
    if ($bundle == 'some_test_bundle') {
        $fields['name'] = clone $base_field_definitions['name'];
        $fields['name']->setDescription('Custom description.');
    }
    return $fields;
}

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