hook_entity_bundle_field_info_alter

hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle)

Alter bundle field definitions.

@todo WARNING: This hook will be changed in https://www.drupal.org/node/2346347.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface[] $fields: The array of bundle field definitions.

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

string $bundle: The bundle.

See also

hook_entity_base_field_info()

hook_entity_base_field_info_alter()

hook_entity_bundle_field_info()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1753
Hooks and documentation related to entities.

Code

function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
  if ($entity_type->id() == 'node' && $bundle == 'article' && !empty($fields['mymodule_text'])) {
    // Alter the mymodule_text field to use a custom class.
    $fields['mymodule_text']->setClass('\Drupal\anothermodule\EntityComputedText');
  }
}
doc_Drupal
2016-10-29 09:17:56
Comments
Leave a Comment

Please login to continue.