class ConstraintValidatorFactory

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.

Hierarchy

Expanded class hierarchy of ConstraintValidatorFactory

2 files declare their use of ConstraintValidatorFactory
ValidationVisitorTest.php in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidationVisitorTest.php
ValidatorTest.php in drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/ValidatorTest.php

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/ConstraintValidatorFactory.php, line 24

Namespace

Symfony\Component\Validator
View source
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];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConstraintValidatorFactory::$validators protected property
ConstraintValidatorFactory::getInstance public function Given a Constraint, this returns the ConstraintValidatorInterface object that should be used to verify its validity. Overrides ConstraintValidatorFactoryInterface::getInstance