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

Alter bundle field definitions.

@todo WARNING: This hook will be changed in https://www.drupal.org/node/2346347.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface[] $fields: The array of bundle field definitions.

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

string $bundle: The bundle.

See also

hook_entity_base_field_info()

hook_entity_base_field_info_alter()

hook_entity_bundle_field_info()

Related topics

2 functions implement hook_entity_bundle_field_info_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_entity_bundle_field_info_alter in core/modules/field/tests/modules/field_test/field_test.module
Implements hook_entity_bundle_field_info_alter().
forum_entity_bundle_field_info_alter in core/modules/forum/forum.module
Implements hook_entity_bundle_field_info_alter().

File

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

Code

function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type
    ->id() == 'node' && $bundle == 'article' && !empty($fields['my_module_text'])) {

    // Alter the my_module_text field to use a custom class.
    $fields['my_module_text']
      ->setClass('\\Drupal\\another_module\\EntityComputedText');
  }
}