function EntitySchemaTestHooks::entityBundleFieldInfo

Implements hook_entity_bundle_field_info().

File

core/modules/system/tests/modules/entity_schema_test/src/Hook/EntitySchemaTestHooks.php, line 70

Class

EntitySchemaTestHooks
Hook implementations for entity_schema_test.

Namespace

Drupal\entity_schema_test\Hook

Code

public function entityBundleFieldInfo(EntityTypeInterface $entity_type, $bundle) {
    if ($entity_type->id() == 'entity_test_update' && $bundle == 'custom') {
        
        /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface $custom_bundle_field_storage */
        $custom_bundle_field_storage = $this->entityFieldStorageInfo($entity_type)['custom_bundle_field'];
        $definitions[$custom_bundle_field_storage->getName()] = FieldDefinition::createFromFieldStorageDefinition($custom_bundle_field_storage);
        return $definitions;
    }
}

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