8.3.x entity.api.php hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)
8.0.x entity.api.php hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)
8.1.x entity.api.php hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)
8.2.x entity.api.php hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)
8.4.x entity.api.php hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)

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 1744
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['mymodule_text'])) {
    // Alter the mymodule_text field to use a custom class.
    $fields['mymodule_text']->setClass('\Drupal\anothermodule\EntityComputedText');
  }
}