* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\Validator\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\Extension\Validator\Constraints\Form; /** * @author Bernhard Schussek */ class ValidationListener implements EventSubscriberInterface { private $validator; private $violationMapper; /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array(FormEvents::POST_SUBMIT => 'validateForm'); } public function __construct(ValidatorInterface $validator, ViolationMapperInterface $violationMapper) { $this->validator = $validator; $this->violationMapper = $violationMapper; } /** * Validates the form and its domain object. * * @param FormEvent $event The event object */ public function validateForm(FormEvent $event) { $form = $event->getForm(); if ($form->isRoot()) { // Validate the form in group "Default" foreach ($this->validator->validate($form) as $violation) { // Allow the "invalid" constraint to be put onto // non-synchronized forms // ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0) $allowNonSynchronized = (null === $violation->getConstraint() || $violation->getConstraint() instanceof Form) && Form::NOT_SYNCHRONIZED_ERROR === $violation->getCode(); $this->violationMapper->mapViolation($violation, $form, $allowNonSynchronized); } } } } __halt_compiler();----SIGNATURE:----NNdvsHP2BcOvlvwURMMvwnBeUW9AXIo7+E7yT3sc+QzsXCwFIQqP5vJUXNuRsC/N2ZGUjffb6jxGD2k6w/IAC6V3u2dTh4rzoOjT2HRPRPYoo96SEDKTPoHzRBqCxvBvKbU6idsijqaP/IYVGN5AK/Mabo+N9QVxFIUA3bZ52Wmd6eiLrf/BfRsGadxuUvl8seF4dpFgl9XQaWYLfr+8oUgBqgrYzV3JXpScGtjm2quzm4JkEZUu468/2mP7HNQwA/L8wCBISbiTXf3TO4cOpVKrug8KtllSA6Tc0avBl47d+1skL388gbgldqox9PjCeXhu6jc6rDitFE0FkSbQN5OylyilGIWKcGPCV+N0BNOQcoDRinmuFU3r99dURKrcAQbrXS1DMMumf87RfrtfyegK2sjALxiPYz5CdvZ/DQ38M2ZgMOXPCWO7VoxA0hBQBxgODLPh2TA+7Oq5XbtGHHBrqbAFE31m+bmHQUUPmJAtuqSAu1er+b81gASaEukqYH39+QoTX0G9G27O0fnrxm+TXpfEuRshSBVK3+vRQX47o7ZjUxRKW0UYpede13jZZaeLeoMshShdU4Gt5IajzPQcll1F6nrmmFOoE2nw5u56jlItFR4+xh9ADIakOhFPeyyyucfVgAVO+tiFrjuvq0vkoz2KJSKffRHLsv62+ow=----ATTACHMENT:----Nzk2NTM2NzQyMTY4OTgzOSA2MTExMjgwMzI3OTI3NTMgNjUyMzIwMjgyNTM1ODExNw==