* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Form\Extension\DataCollector\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; /** * Listener that invokes a data collector for the {@link FormEvents::POST_SET_DATA} * and {@link FormEvents::POST_SUBMIT} events. * * @author Bernhard Schussek */ class DataCollectorListener implements EventSubscriberInterface { private $dataCollector; public function __construct(FormDataCollectorInterface $dataCollector) { $this->dataCollector = $dataCollector; } /** * {@inheritdoc} */ public static function getSubscribedEvents() { return array( // High priority in order to be called as soon as possible FormEvents::POST_SET_DATA => array('postSetData', 255), // Low priority in order to be called as late as possible FormEvents::POST_SUBMIT => array('postSubmit', -255), ); } /** * Listener for the {@link FormEvents::POST_SET_DATA} event. */ public function postSetData(FormEvent $event) { if ($event->getForm()->isRoot()) { // Collect basic information about each form $this->dataCollector->collectConfiguration($event->getForm()); // Collect the default data $this->dataCollector->collectDefaultData($event->getForm()); } } /** * Listener for the {@link FormEvents::POST_SUBMIT} event. */ public function postSubmit(FormEvent $event) { if ($event->getForm()->isRoot()) { // Collect the submitted data of each form $this->dataCollector->collectSubmittedData($event->getForm()); // Assemble a form tree // This is done again after the view is built, but we need it here as the view is not always created. $this->dataCollector->buildPreliminaryFormTree($event->getForm()); } } } __halt_compiler();----SIGNATURE:----ZTgplsYIWk7jDBMNO58uEf2vBvFmdPddikFIt818pYC7533cv1sylzamIeTok+Z2RZq+JxqXN8FbZsLi+W2o/qnzjIBNA1cVckqVo1o5I1jjgilTKA+MHcIemjo/KwyYflvxsDya7ejWIeuJTjumYD9dvtvNmvIV6ZMhQW0aBvSOOm4nDQNvYGfCpb06jE+iccY53w8dnTzwWCNigE7zS2D8pseXIRK7qVvPZLjNScXyoryrtFMNAq/mgI72/S0yH+qlHl0VOR8aCiyrRMihRCjOpe6P3bCfCednjWe3ahbCk0NMFq76H12lmbpLgZuWz44zmqTf/HZ86QdbbYGQFkciwFy2cAqvON1NZm4JMdqI58S7j6UR4K+BHQQnrS2vD1ML2sTnU4PpsEzFAligsy2FUHjgurU9k7K9gw+nmHocXPwMC5s3ahEsVldGd8OlUQkiUJjFpUSXtRAg/VM7spXMmwEwxH0HgJXk7qS4KfKmboFWfoXD4QRgzyYt+hxFEicKBYp/eHz7fM43SbTyUT1ESNP//RH6OSwnqiVmJmhrh8wRSDpYXECue9Q/CH0R+GkGyK0GiDlIRzTvaujVe1/t9ESC3CfLCmE4ETHYdvt8f0CSkew1825mB8LhEch/TduCGXA+iOXYbYdYCvLV1bpugBl+cO0yV/9478wRll4=----ATTACHMENT:----Mjk0MjAwMzU4NTcxNjUwMiAyNTE4NTk2OTMzMzYyMTI2IDg2MDgzOTgzNzE0Mjk1NTg=