function hook_entity_base_field_info_alter
Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info_alter()
- 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info_alter()
- 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info_alter()
Alter base field definitions for a content entity type.
@todo WARNING: This hook will be changed in https://www.drupal.org/node/2346329.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface[] $fields: The array of base field definitions for the entity type.
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.
See also
hook_entity_bundle_field_info()
hook_entity_bundle_field_info_alter()
Related topics
12 functions implement hook_entity_base_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.
- aggregator_display_configurable_test_entity_base_field_info_alter in core/
modules/ aggregator/ tests/ modules/ aggregator_display_configurable_test/ aggregator_display_configurable_test.module - Implements hook_entity_base_field_info_alter().
- CommentDisplayConfigurableTestHooks::entityBaseFieldInfoAlter in core/
modules/ comment/ tests/ modules/ comment_display_configurable_test/ src/ Hook/ CommentDisplayConfigurableTestHooks.php - Implements hook_entity_base_field_info_alter().
- EntityReferenceTestHooks::entityBaseFieldInfoAlter in core/
modules/ system/ tests/ modules/ entity_reference_test/ src/ Hook/ EntityReferenceTestHooks.php - Implements hook_entity_base_field_info_alter().
- EntityTestHooks::entityBaseFieldInfoAlter in core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php - Implements hook_entity_base_field_info_alter().
- entity_test_entity_base_field_info_alter in core/
modules/ system/ tests/ modules/ entity_test/ entity_test.module - Implements hook_entity_base_field_info_alter().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1953
Code
function hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
// Alter the mymodule_text field to use a custom class.
if ($entity_type->id() == 'node' && !empty($fields['mymodule_text'])) {
$fields['mymodule_text']->setClass('\\Drupal\\anothermodule\\EntityComputedText');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.