class ConstraintValidatorFactory in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/validator/ConstraintValidatorFactory.php \Symfony\Component\Validator\ConstraintValidatorFactory
- 8 core/lib/Drupal/Core/Validation/ConstraintValidatorFactory.php \Drupal\Core\Validation\ConstraintValidatorFactory
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/ConstraintValidatorFactory.php \Symfony\Component\Validator\ConstraintValidatorFactory
Default implementation of the ConstraintValidatorFactoryInterface.
This enforces the convention that the validatedBy() method on any Constraint will return the class name of the ConstraintValidator that should validate the Constraint.
@author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
Expanded class hierarchy of ConstraintValidatorFactory
7 files declare their use of ConstraintValidatorFactory
- ConstraintValidatorFactory.php in core/
lib/ Drupal/ Core/ Validation/ ConstraintValidatorFactory.php - Contains \Drupal\Core\Validation\ConstraintValidatorFactory.
- LegacyExecutionContextTest.php in vendor/
symfony/ validator/ Tests/ LegacyExecutionContextTest.php - LegacyValidator2Dot5ApiTest.php in vendor/
symfony/ validator/ Tests/ Validator/ LegacyValidator2Dot5ApiTest.php - LegacyValidatorLegacyApiTest.php in vendor/
symfony/ validator/ Tests/ Validator/ LegacyValidatorLegacyApiTest.php - LegacyValidatorTest.php in vendor/
symfony/ validator/ Tests/ LegacyValidatorTest.php
File
- vendor/
symfony/ validator/ ConstraintValidatorFactory.php, line 25
Namespace
Symfony\Component\ValidatorView source
class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface {
protected $validators = array();
private $propertyAccessor;
public function __construct($propertyAccessor = null) {
$this->propertyAccessor = $propertyAccessor;
}
/**
* {@inheritdoc}
*/
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];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConstraintValidatorFactory:: |
private | property | ||
ConstraintValidatorFactory:: |
protected | property | ||
ConstraintValidatorFactory:: |
public | function |
Given a Constraint, this returns the ConstraintValidatorInterface
object that should be used to verify its validity. Overrides ConstraintValidatorFactoryInterface:: |
1 |
ConstraintValidatorFactory:: |
public | function | 1 |