function hook_entity_base_field_info_alter in Zircon Profile 8.0
Same name and namespace in other branches
- 8 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
3 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.
- 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().
File
- core/
lib/ Drupal/ Core/ Entity/ entity.api.php, line 1694 - 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');
}
}