* * 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:----N75mZYf2XC5/EPO6JDEeW5vobIP55hEv2W3JSRDS9cKu4CkPfke35+Wv5zfJ+mBIkWMKN5xuI9MGMl49KxhyzSXUUTVaNo6o4vWkX5YG4kgVIOd+gyuazxyaC1lO8+hQJQ1739EKVahSGXqnB9QWKKyoUSRX9rB2StPO4gxAettMOicRKe8ExUW4O/dQ6DjZtgmyABrH+g7+C2lDUbcJGeawLRLGhUknIIqYDYnptAiGrAwwrNeZsrg+w0Z9FWINko4fKewMlPCBJT69edf3tWO38ub/9MMv7+IXf2uhPf3mvIxMTVo4jAkpPPf+0Uw4BBpCmfF0SJeAtY7XOcE08iZl0Et7DbqJhncYBQH2IiiXzvfy0cPjyN8qugXJjWgONlvJp513/9r4iNyKFp54zDdjupAP7ygNSw4lxCIeqDczRcQ0jVO+RC7UCnvF+DtKe7etn+xGY8g6aMVXjdQkiXB4skVoarHtwWCxmnDw0NwUJoid5+kXOaVlJlgEs2MXuNlcNKBZ8qG5t2VV3Z/cwEZhAB1Bdajy8inyKxkvI8q6pgwK5EafwfRcipcDQmlHPEAprYKFAQ2ook0KXsqEE7XoaZKNfWb1gc6nlBy2WFJpAGA9nLDPmBaXJLMndJtnzY3GoE8HED4AumtGZRsGx1Bm78apM/IoI1lzjRn2EfM=----ATTACHMENT:----MTI1Nzg1MTExODA5NzIwMyAzNDk2OTcyNjU4Njc0MDgyIDk2OTk0OTA0NzYzNjA0Nzg=