hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type)
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
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/lib/Drupal/Core/Entity/entity.api.php, line 1689
- Hooks and documentation related to entities.
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'); } }
Please login to continue.