function hook_entity_field_storage_info_alter

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_field_storage_info_alter()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_field_storage_info_alter()
  3. 10 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

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);
    }
}

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