function TextTestHooks::entityBundleFieldInfoAlter
Implements hook_entity_bundle_field_info_alter().
Attributes
#[Hook('entity_bundle_field_info_alter')]
File
-
core/
modules/ text/ tests/ modules/ text_test/ src/ Hook/ TextTestHooks.php, line 21
Class
- TextTestHooks
- Hook implementations for text_test.
Namespace
Drupal\text_test\HookCode
public function entityBundleFieldInfoAlter(&$fields, EntityTypeInterface $entity_type, $bundle) : void {
if (($field_name = $this->state
->get('field_test_constraint', FALSE)) && $entity_type->id() == 'node') {
/** @var \Drupal\field\Entity\FieldConfig[] $fields */
$fields[$field_name]->addConstraint('UniqueField');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.