function EntitySchemaTestHooks::entityBundleFieldInfo

Implements hook_entity_bundle_field_info().

Attributes

#[Hook('entity_bundle_field_info')]

File

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

Class

EntitySchemaTestHooks
Hook implementations for entity_schema_test.

Namespace

Drupal\entity_schema_test\Hook

Code

public function entityBundleFieldInfo(EntityTypeInterface $entity_type, $bundle) : array {
  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;
  }
  return [];
}

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