function hook_entity_base_field_info_alter
Same name in other branches
- 9 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
8 functions implement hook_entity_base_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.
- 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().
- entity_reference_test_entity_base_field_info_alter in core/
modules/ system/ tests/ modules/ entity_reference_test/ entity_reference_test.module - 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().
- language_entity_base_field_info_alter in core/
modules/ language/ language.module - Implements hook_entity_base_field_info_alter().
- node_display_configurable_test_entity_base_field_info_alter in core/
modules/ node/ tests/ modules/ node_display_configurable_test/ node_display_configurable_test.module - Implements hook_entity_base_field_info_alter().
File
-
core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1896
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.