function EntitySchemaTestHooks::entityFieldStorageInfo

Implements hook_entity_field_storage_info().

Attributes

#[Hook('entity_field_storage_info')]

File

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

Class

EntitySchemaTestHooks
Hook implementations for entity_schema_test.

Namespace

Drupal\entity_schema_test\Hook

Code

public function entityFieldStorageInfo(EntityTypeInterface $entity_type) : array {
  if ($entity_type->id() == 'entity_test_update') {
    $definitions['custom_bundle_field'] = FieldStorageDefinition::create('string')->setName('custom_bundle_field')
      ->setLabel($this->t('A custom bundle field'))
      ->setRevisionable(TRUE)
      ->setTargetEntityTypeId($entity_type->id());
    return $definitions;
  }
  return [];
}

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