Symfony\Component\Validator\ExecutionContext::addViolation PHP Method

addViolation() public method

public addViolation ( $message, array $params, $invalidValue )
$params array
    public function addViolation($message, array $params, $invalidValue)
    {
        $this->violations->add(new ConstraintViolation(
            $message,
            $params,
            $this->root,
            $this->propertyPath,
            $invalidValue
        ));
    }

Usage Example

 /**
  * Wrapper for $this->context->addViolation()
  *
  * @deprecated
  */
 protected function setMessage($template, array $parameters = array())
 {
     $this->messageTemplate = $template;
     $this->messageParameters = $parameters;
     if (!$this->context instanceof ExecutionContext) {
         throw new ValidatorException('ConstraintValidator::initialize() must be called before setting violation messages');
     }
     $this->context->addViolation($template, $parameters);
 }
All Usage Examples Of Symfony\Component\Validator\ExecutionContext::addViolation