Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_field_storage_info_alter()
  2. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_field_storage_info_alter()

Alter field storage definitions for a content entity type.

Parameters

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $fields: The array of field storage definitions for the entity type.

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

See also

hook_entity_field_storage_info()

Related topics

File

core/lib/Drupal/Core/Entity/entity.api.php, line 2090
Hooks and documentation related to entities.

Code

function hook_entity_field_storage_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {

  // Alter the max_length setting.
  if ($entity_type
    ->id() == 'node' && !empty($fields['my_module_text'])) {
    $fields['my_module_text']
      ->setSetting('max_length', 128);
  }
}