* * 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:----uh6SvnxZRmX4/wB64EqkMwQeTQeS0TdOsRaKBd7/gafM5BEXUxYPNEGjN24UIThfWC020taUAphHQGpPvnru9OVkROUVNZMo4mVkog3nl4SqbsF4f+DC8B8BEN61vpbgYAsqyFBwwvTnR5lgG65UvXA6bFTwQbpQahwqKuPE/6ZDx/eCaDVTv0rlp0y7WuY3G47pZX4wlIdknDZXZfllfOWU37B0m9DhcnlaWEB5eH5u3iFOHaSuOrIlAp3J6g/gV4uso/tpbjcpPl+mHEtSrwK9F0IURLkq+kDYuJk1jDPEkRzzs7mg+DADj9qV+LzoWexAGK4pYgTKTC6ugqFQzo6UpGH3TzE0jI9R8Pa4Mqs2++JXPN8kgSJZoVGRi7d4Kd+Eu2I2el4CrqvhUinOpU1EGjUwXdOJ4EpW/HymvDwt/STqT0TwUph5dlj6lQWxGNOhKfGroll2zpQuIwOEm3X9H9cJx14R1pzn4pzX7/8BEyOQF5X6cbAmsi1YlUIY+nABk5E58PxrSb87URuvIznLRq5iwy2sl4IEOPUUrxcvUndqGJxfcBWTbqtv/UzYJpp9tBc0CVs4Dj4lcHpiE2LCbgObfw1o/WCjUjsHzeDCBAVsgXk0+tmb6Otszx2FvP5OjZPNtcR8X92U5ncvT2Mocm+Pjv326ktW/VHpOpY=----ATTACHMENT:----OTA0OTIyNzYyNzA1MTI1OCA4NDc0MTAxODkxMTc1ODE4IDM0MTc0NjYyOTkzMDQ3OTA=