* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Violation; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\Util\PropertyPath; /** * Default implementation of {@link ConstraintViolationBuilderInterface}. * * @author Bernhard Schussek * * @internal since version 2.5. Code against ConstraintViolationBuilderInterface instead. */ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface { private $violations; private $message; private $parameters; private $root; private $invalidValue; private $propertyPath; private $translator; private $translationDomain; private $plural; private $constraint; private $code; /** * @var mixed */ private $cause; public function __construct(ConstraintViolationList $violations, Constraint $constraint, $message, array $parameters, $root, $propertyPath, $invalidValue, TranslatorInterface $translator, $translationDomain = null) { $this->violations = $violations; $this->message = $message; $this->parameters = $parameters; $this->root = $root; $this->propertyPath = $propertyPath; $this->invalidValue = $invalidValue; $this->translator = $translator; $this->translationDomain = $translationDomain; $this->constraint = $constraint; } /** * {@inheritdoc} */ public function atPath($path) { $this->propertyPath = PropertyPath::append($this->propertyPath, $path); return $this; } /** * {@inheritdoc} */ public function setParameter($key, $value) { $this->parameters[$key] = $value; return $this; } /** * {@inheritdoc} */ public function setParameters(array $parameters) { $this->parameters = $parameters; return $this; } /** * {@inheritdoc} */ public function setTranslationDomain($translationDomain) { $this->translationDomain = $translationDomain; return $this; } /** * {@inheritdoc} */ public function setInvalidValue($invalidValue) { $this->invalidValue = $invalidValue; return $this; } /** * {@inheritdoc} */ public function setPlural($number) { $this->plural = $number; return $this; } /** * {@inheritdoc} */ public function setCode($code) { $this->code = $code; return $this; } /** * {@inheritdoc} */ public function setCause($cause) { $this->cause = $cause; return $this; } /** * {@inheritdoc} */ public function addViolation() { if (null === $this->plural) { $translatedMessage = $this->translator->trans( $this->message, $this->parameters, $this->translationDomain ); } else { try { $translatedMessage = $this->translator->transChoice( $this->message, $this->plural, $this->parameters, $this->translationDomain ); } catch (\InvalidArgumentException $e) { $translatedMessage = $this->translator->trans( $this->message, $this->parameters, $this->translationDomain ); } } $this->violations->add(new ConstraintViolation( $translatedMessage, $this->message, $this->parameters, $this->root, $this->propertyPath, $this->invalidValue, $this->plural, $this->code, $this->constraint, $this->cause )); } } __halt_compiler();----SIGNATURE:----O9eHs/L+LpuB1Rs6B8iRArLwRsHc92GCIwp8KYWz+sO6EoI2wALAa/xn1nnmK4keOCg2aHE1yzH9V2zCC9VeO7mUp5UNPncV8bvIB1AScplzl3uHIcjYHxV/ZsVOcMlvolDiUpckhlKm5kTyKz4G9ooYwKcAnzk6CP3atVKC0LHjf5UovdCK8CjwvT99s36uG3l602bDtXkXhrZgWXaw7QNvsAJmSxS6XQ/wOin4LZRKZJSNjWs+pgqyIeuwVT6GmJjt5tdaNXkOc1qK1yGa/LRki1K9L4KmD7NVNcTSVPDIJ5H+Uy5JD+9I70UyoXXuNAxtBxP9OwxXOFOWSu7am7NmdZYXqrN01wdfAHexFWSy13yZHHsqfzljIin3hNsPuWdOehjFB6E8NQQPjMqUggp+h55rLUlAwQxU/splcuuXU4a4dsfesmw9Tt/uBuj5azQPXt+4MPy38l44zyTFWcsqunXq0CO8fgGkic9zzhhYkVgQ81yPZ4QO/64eN/bv0ZqpX3dpIStocLeQlXX9qvt/gJKCe7UJChV9Hnz0buZR6igvxRCB9O2HX3augOddDWmlYH8lhI0Zant0iZZ1sc1j4pWSFRn0L+79Rxuk/k1gZZbgxEvXQv7O8cbGkd3wZfg0jDDqtIs+BuchvEbHECif0W/kDKR/h6fwK4RPCc0=----ATTACHMENT:----MzM4Mzc2MjQ5NzE0MjkwNyA5NjI1NzE3NzM4NDY1MDAyIDgwODU5NTc0ODcyODQ2NTg=