propertyPath = PropertyPath::append($this->propertyPath, (string) $path); return $this; } /** * {@inheritdoc} */ public function setParameter(string $key, mixed $value): static { $this->parameters[$key] = $value; return $this; } /** * {@inheritdoc} */ public function setParameters(array $parameters): static { $this->parameters = $parameters; return $this; } /** * {@inheritdoc} */ public function setTranslationDomain(string $translationDomain): static { $this->translationDomain = $translationDomain; return $this; } /** * {@inheritdoc} */ public function setInvalidValue(mixed $invalidValue): static { $this->invalidValue = $invalidValue; return $this; } /** * {@inheritdoc} */ public function setPlural(int $number): static { $this->plural = $number; return $this; } /** * {@inheritdoc} */ public function setCode(?string $code): static { $this->code = $code; return $this; } /** * {@inheritdoc} */ public function setCause(mixed $cause): static { $this->cause = $cause; return $this; } /** * {@inheritdoc} */ public function addViolation(): void { 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 )); } /** * {@inheritdoc} */ public function disableTranslation(): static { $this->translationDomain = FALSE; return $this; } }