* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator; use Psr\Container\ContainerInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\ValidatorException; /** * Uses a service container to create constraint validators. * * @author Kris Wallsmith */ class ContainerConstraintValidatorFactory implements ConstraintValidatorFactoryInterface { private $container; private $validators; public function __construct(ContainerInterface $container) { $this->container = $container; $this->validators = array(); } /** * {@inheritdoc} * * @throws ValidatorException When the validator class does not exist * @throws UnexpectedTypeException When the validator is not an instance of ConstraintValidatorInterface */ public function getInstance(Constraint $constraint) { $name = $constraint->validatedBy(); if (!isset($this->validators[$name])) { if ($this->container->has($name)) { $this->validators[$name] = $this->container->get($name); } else { if (!class_exists($name)) { throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or it is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, get_class($constraint))); } $this->validators[$name] = new $name(); } } if (!$this->validators[$name] instanceof ConstraintValidatorInterface) { throw new UnexpectedTypeException($this->validators[$name], ConstraintValidatorInterface::class); } return $this->validators[$name]; } } __halt_compiler();----SIGNATURE:----kAB29G8Zs2ZqTZtrjOWBoHQsNn6OD9e0vja2iglFp7JaI+bpFg2nEVm9flQ/HtYEgL1JBJux3LBWSwb2WYCicC2rJgSsMMSmayoJN4j+MKOYJldtlthvlPJ/TADN47pwEWWfPQfXMoVKsdp4EviXQeqGUSWP9h2T7xauyGbUq7/DB/5KXMpRbDl+HqBi46BIJTrv3E0/yhY5bg45kxQh5wMRKct4ofdtxt7eR/I2U3yFU167onuQ2VtlIN2SbFGd5039LQHtD8ghfrqwJiQp8d9yYo3NMj0DtA2k0MxpBrUCEpf2NNSFpwfbd9tKHOoZOZ5r8WAmhobB8T23KbXfg4o/4RSyIkY9431RrCugCL2OfDLVDKiYO65YzDRJQJK14PFugMhzGjvXcbBJu4P+to7oOfeah3MadbR5qK1hSbESNnCFtobYbpmDPM8qDfwKPDWBsUXRD2kYwQoWzQz8JIklmxd/r9rwnFY6FfIZvzdB9e4nSFaJ3OEbgygjzRdK/A3tIhieoL1pettibnGENWBLV5v7fkZJ41CXbj1Ony1cyaRTxfmwQ46NXR6/egWiHI3YnpV774b1mZJ0SUqPA01PRtWqeOqMf+pi/km526k08sS4qOfs1VctaPwhfnL7oejQc1hoBUK8bZHzSY/GIdVbHaaOdKNhw0bQz7J0kuM=----ATTACHMENT:----ODE3NDU2NTQwODY5MTkxMiA5MjkyNTAzNjkxMzcwMDQzIDM5MDQwOTY5NzEwMzIzNzA=