我试图在我在侦听器中创建的响应中插入以表单(电子邮件)传递的数据,以确保响应是一个 json 对象。
我无法以任何方式从“事件”中获取表单数据..
有我想要的解决方案吗?
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::PROFILE_EDIT_SUCCESS => 'onProfileEditSuccess',
);
}
public function onProfileEditSuccess(FormEvent $event)
{
$response = new Response();
$output = array('success' => true, 'new_mail' => $event); //event return empty object
$response->headers->set('Content-Type', 'application/json');
$response->setContent(json_encode($output));
$event->setResponse($response);
}
我试图听事件 COMPLETED,但没有让我改变响应!