I'm using FOSUserBundle with Symfony 4.
When we are updating an user profile, if all is ok. An event is triggered here.
$this->eventDispatcher->dispatch(FOSUserEvents::PROFILE_EDIT_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
When this event is triggered, this method is called from FlashListenner
public function addSuccessFlash(Event $event, $eventName)
{
if (!isset(self::$successMessages[$eventName])) {
throw new \InvalidArgumentException('This event does not correspond to a known flash message');
}
$this->session->getFlashBag()->add('success', $this->trans(self::$successMessages[$eventName]));
}
But, my question is : How can I catch this flashbag is the next called controller in order to know If there is a flash message to print or not ? Thanks for your help.