diff --git a/controller.rst b/controller.rst
index 3ef67d063d7..8b6c211d74b 100644
--- a/controller.rst
+++ b/controller.rst
@@ -407,7 +407,7 @@ and then redirects. The message key (``notice`` in this example) can be anything
you'll use this key to retrieve the message.
In the template of the next page (or even better, in your base layout template),
-read any flash messages from the session:
+read any flash messages from the session using ``app.flashes()``:
.. configuration-block::
@@ -416,17 +416,17 @@ read any flash messages from the session:
{# app/Resources/views/base.html.twig #}
{# you can read and display just one flash message type... #}
- {% for flash_message in app.session.flashBag.get('notice') %}
+ {% for message in app.flashes('notice') %}
- {{ flash_message }}
+ {{ message }}
{% endfor %}
{# ...or you can read and display every flash message available #}
- {% for type, flash_messages in app.session.flashBag.all %}
- {% for flash_message in flash_messages %}
-
- {{ flash_message }}
+ {% for label, messages in app.flashes %}
+ {% for message in messages %}
+
+ {{ message }}
{% endfor %}
{% endfor %}
@@ -451,6 +451,10 @@ read any flash messages from the session:
+.. versionadded:: 3.3
+ The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
+ you had to use ``app.session.flashBag``.
+
.. note::
It's common to use ``notice``, ``warning`` and ``error`` as the keys of the
diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst
index b88027df765..eab009aa038 100644
--- a/quick_tour/the_controller.rst
+++ b/quick_tour/the_controller.rst
@@ -331,12 +331,16 @@ And you can display the flash message in the template like this:
.. code-block:: html+twig
- {% for flashMessage in app.session.flashBag.get('notice') %}
+ {% for message in app.flashes('notice') %}
- {{ flashMessage }}
+ {{ message }}
{% endfor %}
+.. versionadded:: 3.3
+ The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
+ you had to use ``app.session.flashBag``.
+
Final Thoughts
--------------
diff --git a/session/avoid_session_start.rst b/session/avoid_session_start.rst
index 896ed8dd9c1..4dd53ec5b78 100644
--- a/session/avoid_session_start.rst
+++ b/session/avoid_session_start.rst
@@ -15,9 +15,9 @@ that a session is *always* started:
.. code-block:: html+twig
- {% for flashMessage in app.session.flashBag.get('notice') %}
+ {% for message in app.flashes('notice') %}
- {{ flashMessage }}
+ {{ message }}
{% endfor %}
@@ -30,9 +30,13 @@ access the flash messages:
.. code-block:: html+twig
{% if app.request.hasPreviousSession %}
- {% for flashMessage in app.session.flashBag.get('notice') %}
+ {% for message in app.flashes('notice') %}
- {{ flashMessage }}
+ {{ message }}
{% endfor %}
{% endif %}
+
+.. versionadded:: 3.3
+ The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3
+ you had to use ``app.session.flashBag``.