* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Validator for Callback constraint. * * @author Bernhard Schussek */ class CallbackValidator extends ConstraintValidator { /** * {@inheritdoc} */ public function validate($object, Constraint $constraint) { if (!$constraint instanceof Callback) { throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Callback'); } $method = $constraint->callback; if ($method instanceof \Closure) { $method($object, $this->context, $constraint->payload); } elseif (is_array($method)) { if (!is_callable($method)) { if (isset($method[0]) && is_object($method[0])) { $method[0] = get_class($method[0]); } throw new ConstraintDefinitionException(sprintf('%s targeted by Callback constraint is not a valid callable', json_encode($method))); } call_user_func($method, $object, $this->context, $constraint->payload); } elseif (null !== $object) { if (!method_exists($object, $method)) { throw new ConstraintDefinitionException(sprintf('Method "%s" targeted by Callback constraint does not exist in class %s', $method, get_class($object))); } $reflMethod = new \ReflectionMethod($object, $method); if ($reflMethod->isStatic()) { $reflMethod->invoke(null, $object, $this->context, $constraint->payload); } else { $reflMethod->invoke($object, $this->context, $constraint->payload); } } } } __halt_compiler();----SIGNATURE:----nUB//V+9T3F7gfrUE3qEeqp3Y7q3L9cZgXF9kkRDc11Wuk08VtuE8IjnFzp9h+xpxCOwiCO/hIJn93ZzESaeqb2qZptzVtPiUM+E20Zc0gZ1abzckEezznXu3Pen79MeWMupqEPanTmBA/QeB/p+PdXvlQUAkrVbDrq2zC71NMbG98tpxGhTECRSxK0Mka5cdQkCIC8Orrk4o/Ahzh+FKpHajUpxYM7Jj2W0LPFeTLufxd8Y2d8xaRBnjSxkJG3AREDvsa2ne5AgyK5GEUpjjTge8bxRCpRIpBrXWWz0VCE27BlXUE83uRLfrSODjgS9LdFdv6ntw1WftLyI6jmswZPJKZRUAjcrhUQJz11akGhxtZdw7uQEICB4QVhM+s3oFfyVlXoIRPdqs+qPXgIyXxL03fzV7D5Z5EW4UhAUK7lM+yMd9cJeZCOZKZOBJ64zT5jmFzEfuXoBS5pa3HbYBXVSLCf4Y+3MPaZA2H8nLfgJOQsrLzGt4vKB+rF4a4m9VOF+HQUL1Ybx51/rhYGsepie2NwaTEcuWm69MWf8YbWkM31Fsp8FG4l66cySEpx9vSbriUI/kYKUptlD//CwblfTiTfzfkHGq+suKMDDaI4Z6UpFvYnmunMdSgnaRJSbOORdo2OEGeKm0C/2qC0XGTozPK0VBGPTUzXBR8hH5Ek=----ATTACHMENT:----NTMwOTY0OTcwODI4MzU3OCA4ODAwNDc5NjA3NjcyNjk3IDc5NDU3Mjc2MjgzNjY0NDQ=