function hook_entity_base_field_info_alter

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info_alter()
  2. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_base_field_info_alter()
  3. 10 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_base_field_info()

hook_entity_bundle_field_info()

hook_entity_bundle_field_info_alter()

Related topics

7 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.

comment_display_configurable_test_entity_base_field_info_alter in core/modules/comment/tests/modules/comment_display_configurable_test/comment_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().
path_entity_base_field_info_alter in core/modules/path/path.module
Implements hook_entity_base_field_info_alter().

... See full list

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1970

Code

function hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
    // Alter the my_module_text field to use a custom class.
    if ($entity_type->id() == 'node' && !empty($fields['my_module_text'])) {
        $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.