function ConfigExistsConstraintValidator::validate
Same name in other branches
- 11.x core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraintValidator.php \Drupal\Core\Config\Plugin\Validation\Constraint\ConfigExistsConstraintValidator::validate()
File
-
core/
lib/ Drupal/ Core/ Config/ Plugin/ Validation/ Constraint/ ConfigExistsConstraintValidator.php, line 45
Class
- ConfigExistsConstraintValidator
- Validates that a given config object exists.
Namespace
Drupal\Core\Config\Plugin\Validation\ConstraintCode
public function validate(mixed $name, Constraint $constraint) {
assert($constraint instanceof ConfigExistsConstraint);
// This constraint may be used to validate nullable (optional) values.
if ($name === NULL) {
return;
}
if (!in_array($constraint->prefix . $name, $this->configFactory
->listAll($constraint->prefix), TRUE)) {
$this->context
->addViolation($constraint->message, [
'@name' => $constraint->prefix . $name,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.