* * 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:----J7fQ8largQk9r3pGWj1TWW1taAz7Emt+EQ4jcN1cjXPyp6+vlXyqzUhipgdCsH9psaWBFDgllXJDMuYkXMvUEA6zdcTHsbsQgSwi74YHJEPR1RhvwH8WsvUAW4fLqCPiIut7Hur7xyXX6Wy78U/RTxeb1QtQtoEn/ENzuyn52PDIXMYOpODepHsh/8vBD45cBWln5H9pjJXhIkJkx+9PTS23/B63/wqnucY4hwF4MZoEy8DMPDpXAWRsqeWmeT0vx1aAm4ItDqDRr6wvVbX35wwoxxNVzSokORDPmRye4eJyd3w4yjoV1OYAU+jQAYhEFUJEvqnQtVrwJLc0y9dFEH8uTMEDrKvkkCGcTakOcLdIWYTBrMTLn8JfAC5aYgWW5gup+Tpx3jkUvJ1U5o+0NJj/AdDHuIe5PbGZHHJ0cveKGk7Sk2y07tuUdOSq+GoCovaj3JTaBoWN2UR3oYaFyBK1ZtDd3Y5EfbWOtNR9lCpIdoqj43JlPBEnmnGSRz/OAcf13neL1AZXps+C4T+Or2ieqXYbffB2sL9CSBySdyeI9YffZyDg2W25fwnbOsj0mzOUiuA1swGxh6f3IIa52d85xy6Q6TxbyqKmDs54LXZfekgOqpKahoMr8ua2zvLu8Vn30vpiqZnhdCsOhWjcr0vjRQA0iBp2OVp8K+wChD0=----ATTACHMENT:----MzM4NjYzNzU1NDUyNjggMjAzNDg3NzY3NzgwODI5NCA5OTQ4NDY2MzczNzg3MTU2