0

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.

Minirock
  • 628
  • 3
  • 13
  • 28

1 Answers1

0

If you have the same issue: There is the solution:

{% for msg in app.session.flashBag.get('success') %}

Minirock
  • 628
  • 3
  • 13
  • 28