Default implementation of the ConstraintValidatorFactoryInterface.
This enforces the convention that the validatedBy() method on any Constrain will return the class name of the ConstraintValidator that should validate the Constraint.
Expanded class hierarchy of ConstraintValidatorFactory
class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface {
protected $validators = array();
/**
* {@inheritDoc}
*/
public function getInstance(Constraint $constraint) {
$className = $constraint
->validatedBy();
if (!isset($this->validators[$className])) {
$this->validators[$className] = new $className();
}
return $this->validators[$className];
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConstraintValidatorFactory:: |
protected | property | ||
ConstraintValidatorFactory:: |
public | function |
Given a Constraint, this returns the ConstraintValidatorInterface
object that should be used to verify its validity. Overrides ConstraintValidatorFactoryInterface:: |