You are here

public function ExecutionContext::addViolation in Plug 7

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

Adds a violation at the current node of the validation graph.

Note: the parameters $invalidValue, $plural and $code are deprecated since version 2.5 and will be removed in 3.0.

@api

Parameters

string $message The error message:

array $params 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::addViolation

1 call to ExecutionContext::addViolation()
LegacyExecutionContext::addViolation in lib/Symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php
Adds a violation at the current node of the validation graph.
1 method overrides ExecutionContext::addViolation()
LegacyExecutionContext::addViolation in lib/Symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php
Adds a violation at the current node of the validation graph.

File

lib/Symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php, line 184

Class

ExecutionContext
The context used and created by {@link ExecutionContextFactory}.

Namespace

Symfony\Component\Validator\Context

Code

public function addViolation($message, array $parameters = array(), $invalidValue = null, $plural = null, $code = null) {

  // The parameters $invalidValue and following are ignored by the new
  // API, as they are not present in the new interface anymore.
  // You should use buildViolation() instead.
  if (func_num_args() > 2) {
    throw new BadMethodCallException('The parameters $invalidValue, $pluralization and $code are ' . 'not supported anymore as of Symfony 2.5. Please use ' . 'buildViolation() instead or enable the legacy mode.');
  }
  $this->violations
    ->add(new ConstraintViolation($this->translator
    ->trans($message, $parameters, $this->translationDomain), $message, $parameters, $this->root, $this->propertyPath, $this->value, null, null, $this->constraint));
}