You are here

public function ExecutionContext::addViolationAt in Plug 7

Same name in this branch
  1. 7 lib/Symfony/validator/Symfony/Component/Validator/ExecutionContext.php \Symfony\Component\Validator\ExecutionContext::addViolationAt()
  2. 7 lib/Symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::addViolationAt()

Adds a violation at the validation graph node with the given property path relative to the current property path.

@api

Parameters

string $subPath The relative property path for the violation:

string $message The error message:

array $parameters The parameters substituted in the error message:

mixed $invalidValue The invalid, validated value:

int|null $plural The number to use to pluralize of the message:

int|null $code The violation code:

Overrides ExecutionContextInterface::addViolationAt

Deprecated

Deprecated since version 2.5, to be removed in Symfony 3.0. Use {@link Context\ExecutionContextInterface::buildViolation()} instead.

File

lib/Symfony/validator/Symfony/Component/Validator/ExecutionContext.php, line 121

Class

ExecutionContext
Default implementation of {@link ExecutionContextInterface}.

Namespace

Symfony\Component\Validator

Code

public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) {
  $this->globalContext
    ->getViolations()
    ->add(new ConstraintViolation(null === $plural ? $this->translator
    ->trans($message, $parameters, $this->translationDomain) : $this->translator
    ->transChoice($message, $plural, $parameters, $this->translationDomain), $message, $parameters, $this->globalContext
    ->getRoot(), $this
    ->getPropertyPath($subPath), func_num_args() >= 4 ? $invalidValue : $this->value, $plural, $code));
}