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\Tests\Fixtures
;
14 use Symfony\Component\Form\FormEvents
;
15 use Symfony\Component\Form\FormEvent
;
16 use Symfony\Component\EventDispatcher\EventSubscriberInterface
;
18 class FixedFilterListener
implements EventSubscriberInterface
22 public function __construct(array $mapping)
24 $this->mapping
= array_merge(array(
25 'preSubmit' => array(),
26 'onSubmit' => array(),
27 'preSetData' => array(),
31 public function preSubmit(FormEvent
$event)
33 $data = $event->getData();
35 if (isset($this->mapping
['preSubmit'][$data])) {
36 $event->setData($this->mapping
['preSubmit'][$data]);
40 public function onSubmit(FormEvent
$event)
42 $data = $event->getData();
44 if (isset($this->mapping
['onSubmit'][$data])) {
45 $event->setData($this->mapping
['onSubmit'][$data]);
49 public function preSetData(FormEvent
$event)
51 $data = $event->getData();
53 if (isset($this->mapping
['preSetData'][$data])) {
54 $event->setData($this->mapping
['preSetData'][$data]);
58 public static function getSubscribedEvents()
61 FormEvents
::PRE_SUBMIT
=> 'preSubmit',
62 FormEvents
::SUBMIT
=> 'onSubmit',
63 FormEvents
::PRE_SET_DATA
=> 'preSetData',