Source of file ConstraintValidatorFactory.php
Size: 1,098 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Component/Validator/ConstraintValidatorFactory.php
123456789101112131415161718192021222324252627282930313233343536373839404142 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Constraint; /** * 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. */ 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]; } } |