From 0b4d86af8cafa5413bfbd787be1818866541033f Mon Sep 17 00:00:00 2001 From: Oleg Andreyev Date: Mon, 22 Jun 2020 19:29:34 +0300 Subject: [PATCH 1/2] adding warning about depending on concrete implementation of Session --- controller.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controller.rst b/controller.rst index 9cbb20101cc..d4f35396a4b 100644 --- a/controller.rst +++ b/controller.rst @@ -534,6 +534,14 @@ After processing the request, the controller sets a flash message in the session and then redirects. The message key (``notice`` in this example) can be anything: you'll use this key to retrieve the message. +.. warning:: + + If you want avoid depending on concrete implementation of `Session` and relay on :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`: + you will find your self in a situation that `getFlashBag` is not declared in an interface. + In order fix this "problem" you must inject `FlashBagInterface`/`session.flash_bag` and relay on `FlashBagInterface` + instead of `Session` for access to "Flash Messages" + + In the template of the next page (or even better, in your base layout template), read any flash messages from the session using ``app.flashes()``: From 0d22bbb92a7f74a57bafd6c47d53257424cfda77 Mon Sep 17 00:00:00 2001 From: Oleg Andreyev Date: Mon, 22 Jun 2020 22:45:43 +0300 Subject: [PATCH 2/2] fixing typo --- controller.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller.rst b/controller.rst index d4f35396a4b..ad3e99d90b6 100644 --- a/controller.rst +++ b/controller.rst @@ -536,7 +536,7 @@ you'll use this key to retrieve the message. .. warning:: - If you want avoid depending on concrete implementation of `Session` and relay on :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`: + If you want avoid depending on concrete implementation of `Session` and rely on :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`: you will find your self in a situation that `getFlashBag` is not declared in an interface. In order fix this "problem" you must inject `FlashBagInterface`/`session.flash_bag` and relay on `FlashBagInterface` instead of `Session` for access to "Flash Messages"