* * 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:----G5pdJJS8QiZrsvpcVs3RTIFL1yVMTzRlQMjPnl5o2Y9OehsPj55qXuIgbdIh3OFsO7hBU9yUCsTd7vU1aTS01j9J9rbPnthT3ShZw1iTsjg4FrYdk+l4Q1Cc3KwlJF2dgCvh3nuINWTa12b92WHcnUUsPaAQ3qLDPdF8lY8t1L9KuEq1c2AVxtBDNhOQaNu63ZvH5WnwuFERU2anO/hJY8FACNDtMF9Wxp+K+eE0HrfeYf4Sl3drUefg6AqFha0pqdegbPvGZ4EsnNlawhKyqe0xmFqSpa68bAYwPymQZ3HcnWwcvGnin2Jl/u5AzQbgybWINImWrVbU8DpzTMTLIw/mVhTj3VYexI63tQEieRFOERT6x2b6lCmhr/i7J+s+LL1Qjf/V9APtIyYxuRuADlAQWuDp9TymjgAavQF0r+ZBTxsIKCvj2aLzYYpt118utffY8gm7a3pc+oqpvKb7WFZjTtJPCmvzhezxdm/sZqxl9/Z1TQXJ2wI7iIDGmS5m/Xk1omiJGX3W+Xq/IbiWgsNu8NecjPc1kpnqxWyDjSPLdj77JrHBQMm89X3gFqy9u9YNoHx2/5jjpFCK3L91VDetujgTj6D322iWc53t66qKUGhITtYgSRl3YuqGcy6yQ5LmJMvbvNOMjnKMK0s0tTZ5uBdO8Cmt1r3p9ZJlQF4=----ATTACHMENT:----MjE0OTQ1NDc4OTY4ODE0MiA5MDExNTcxNTU0Njk1NTc1IDYwMTMzNDkwMzU0NTIyNTg=