Example #1
0
 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if ($constraint->isClosure()) {
         $function = $constraint->getClosure();
     } else {
         if (is_string($constraint->getService())) {
             $service = $this->container->get($constraint->getService());
         } else {
             $service = $constraint->getService();
         }
         $function = array($service, $constraint->getMethod());
     }
     call_user_func($function, $this->getErrorElement($value), $value);
 }
 public function isValid($value, Constraint $constraint)
 {
     $errorElement = new ErrorElement($value, $this->constraintValidatorFactory, $this->context, $this->context->getGroup());
     if ($constraint->isClosure()) {
         $function = $constraint->getClosure();
     } else {
         if (is_string($constraint->getService())) {
             $service = $this->container->get($constraint->getService());
         } else {
             $service = $constraint->getService();
         }
         $function = array($service, $constraint->getMethod());
     }
     call_user_func($function, $errorElement, $value);
     return count($this->context->getViolations()) == 0;
 }