我有一个类,哪些方法订阅了两个事件
<?php
namespace AppBundle\Listener;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
class WatermarkListener implements EventSubscriberInterface
{
private $data;
public static function getSubscribedEvents()
{
return array(
FormEvents::PRE_SUBMIT => 'onPreSetData',
);
}
public function postUpload(Event $event)
{
dump($event);
dump($this->data);
exit;
}
public function onPresetData(FormEvent $event)
{
$this->data = $event->getData();
dump($this->data);
}
}
首先触发 FormEvents::PRE_SUBMIT
并填充$this->data
问题是当第二个事件postUpload
被触发时,$this->data
的值为空。如何在这两个事件调用之间保留$this->data
中的数据?