You are here

public function ConstraintValidatorFactory::getInstance in Plug 7

Given a Constraint, this returns the ConstraintValidatorInterface object that should be used to verify its validity.

Parameters

Constraint $constraint The source constraint:

Return value

ConstraintValidatorInterface

Overrides ConstraintValidatorFactoryInterface::getInstance

File

lib/Symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php, line 39

Class

ConstraintValidatorFactory
Default implementation of the ConstraintValidatorFactoryInterface.

Namespace

Symfony\Component\Validator

Code

public function getInstance(Constraint $constraint) {
  $className = $constraint
    ->validatedBy();
  if (!isset($this->validators[$className])) {
    $this->validators[$className] = 'validator.expression' === $className ? new ExpressionValidator($this->propertyAccessor) : new $className();
  }
  return $this->validators[$className];
}