4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Extension\Validator\Type
;
14 use Symfony\Component\Form\AbstractTypeExtension
;
15 use Symfony\Component\OptionsResolver\Options
;
16 use Symfony\Component\OptionsResolver\OptionsResolverInterface
;
19 * Encapsulates common logic of {@link FormTypeValidatorExtension} and
20 * {@link SubmitTypeValidatorExtension}.
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 abstract class BaseValidatorExtension
extends AbstractTypeExtension
29 public function setDefaultOptions(OptionsResolverInterface
$resolver)
31 // Make sure that validation groups end up as null, closure or array
32 $validationGroupsNormalizer = function (Options
$options, $groups) {
33 if (false === $groups) {
41 if (is_callable($groups)) {
45 return (array) $groups;
48 $resolver->setDefaults(array(
49 'validation_groups' => null,
52 $resolver->setNormalizers(array(
53 'validation_groups' => $validationGroupsNormalizer,