diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php deleted file mode 100644 index 1f62e060..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Extension\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvents; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
17 | use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; | ||
18 | |||
19 | /** | ||
20 | * Takes care of converting the input from a list of checkboxes to a correctly | ||
21 | * indexed array. | ||
22 | * | ||
23 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
24 | */ | ||
25 | class FixCheckboxInputListener implements EventSubscriberInterface | ||
26 | { | ||
27 | private $choiceList; | ||
28 | |||
29 | /** | ||
30 | * Constructor. | ||
31 | * | ||
32 | * @param ChoiceListInterface $choiceList | ||
33 | */ | ||
34 | public function __construct(ChoiceListInterface $choiceList) | ||
35 | { | ||
36 | $this->choiceList = $choiceList; | ||
37 | } | ||
38 | |||
39 | public function preSubmit(FormEvent $event) | ||
40 | { | ||
41 | $values = (array) $event->getData(); | ||
42 | $indices = $this->choiceList->getIndicesForValues($values); | ||
43 | |||
44 | $event->setData(count($indices) > 0 ? array_combine($indices, $values) : array()); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * Alias of {@link preSubmit()}. | ||
49 | * | ||
50 | * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use | ||
51 | * {@link preSubmit()} instead. | ||
52 | */ | ||
53 | public function preBind(FormEvent $event) | ||
54 | { | ||
55 | $this->preSubmit($event); | ||
56 | } | ||
57 | |||
58 | public static function getSubscribedEvents() | ||
59 | { | ||
60 | return array(FormEvents::PRE_SUBMIT => 'preSubmit'); | ||
61 | } | ||
62 | } | ||