public function ConstraintValidatorFactory::getInstance in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Validation/ConstraintValidatorFactory.php \Drupal\Core\Validation\ConstraintValidatorFactory::getInstance()
File
- core/
lib/ Drupal/ Core/ Validation/ ConstraintValidatorFactory.php, line 29
Class
- ConstraintValidatorFactory
- Defines a constraint validator factory that works with container injection.
Namespace
Drupal\Core\ValidationCode
public function getInstance(Constraint $constraint) {
$class_name = $constraint
->validatedBy();
// Constraint validator instances should always be initialized newly and
// never shared, because the current validation context is getting injected
// into them through setter injection and in a case of a recursive
// validation where a validator triggers a validation chain leading to the
// same validator the context of the first call would be exchanged with the
// one of the subsequent validation chain.
return $this->classResolver
->getInstanceFromDefinition($class_name);
}