unique_field_constraint_test.module in Drupal 10
Contains unique_field_constraint_test.module.
File
core/modules/system/tests/modules/unique_field_constraint_test/unique_field_constraint_test.moduleView source
<?php
/**
* @file
* Contains unique_field_constraint_test.module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_entity_base_field_info_alter().
*/
function unique_field_constraint_test_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
if ($entity_type
->id() === 'entity_test_string_id') {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields['name']
->addConstraint('UniqueField');
}
}
Functions
Name | Description |
---|---|
unique_field_constraint_test_entity_base_field_info_alter | Implements hook_entity_base_field_info_alter(). |