function field_validation_entity_base_field_info_alter in Field Validation 8
Implements hook_entity_base_field_info_alter().
File
- ./
field_validation.module, line 40 - field validation.
Code
function field_validation_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
$rulesets = \Drupal::entityTypeManager()
->getStorage('field_validation_rule_set')
->loadByProperties([
'entity_type' => $entity_type
->id(),
]);
foreach ($rulesets as $ruleset_name => $ruleset) {
$rules = $ruleset
->getFieldValidationRules();
foreach ($rules as $field_validation_rule) {
$field_name = $field_validation_rule
->getFieldName();
if (isset($fields[$field_name])) {
$fields[$field_name]
->addConstraint('FieldValidationConstraint', [
'ruleset_name' => $ruleset_name,
'rule_uuid' => '',
]);
}
}
}
}