function hook_entity_bundle_field_info_alter
Same name and namespace in other branches
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_field_info_alter()
- 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_field_info_alter()
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_bundle_field_info_alter()
- main 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_alter()
hook_entity_bundle_field_info()
Related topics
4 functions implement hook_entity_bundle_field_info_alter()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- EntityBundleInfoAlter in core/
modules/ media/ tests/ modules/ media_test_oembed/ src/ Hook/ EntityBundleInfoAlter.php - Alters media bundles.
- FieldTestHooks::entityBundleFieldInfoAlter in core/
modules/ field/ tests/ modules/ field_test/ src/ Hook/ FieldTestHooks.php - Implements hook_entity_bundle_field_info_alter().
- ImagePropertyConstraintValidationHooks::entityBundleFieldInfoAlter in core/
modules/ image/ tests/ modules/ image_field_property_constraint_validation/ src/ Hook/ ImagePropertyConstraintValidationHooks.php - Implements hook_entity_bundle_field_info_alter().
- TextTestHooks::entityBundleFieldInfoAlter in core/
modules/ text/ tests/ modules/ text_test/ src/ Hook/ TextTestHooks.php - Implements hook_entity_bundle_field_info_alter().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 2074
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');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.