From 4d31c4be5c20c04e6a882a302f48f8be40eaa4e1 Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Sat, 25 Mar 2017 14:56:04 +0100 Subject: [PATCH 1/4] Changed the flash messages. --- controller.rst | 12 ++++++------ quick_tour/the_controller.rst | 4 ++-- session/avoid_session_start.rst | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/controller.rst b/controller.rst index 3ef67d063d7..1abb6437987 100644 --- a/controller.rst +++ b/controller.rst @@ -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 %} diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst index b88027df765..3026fd9224e 100644 --- a/quick_tour/the_controller.rst +++ b/quick_tour/the_controller.rst @@ -331,9 +331,9 @@ 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 %} diff --git a/session/avoid_session_start.rst b/session/avoid_session_start.rst index 896ed8dd9c1..e19498184cf 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,9 @@ 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 %} From a1af4492eda6aa46ab4368434c3d03241490085b Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Sat, 25 Mar 2017 16:34:25 +0100 Subject: [PATCH 2/4] Adding notice about new method. --- controller.rst | 6 +++++- quick_tour/the_controller.rst | 4 ++++ session/avoid_session_start.rst | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/controller.rst b/controller.rst index 1abb6437987..fd94523aa8e 100644 --- a/controller.rst +++ b/controller.rst @@ -425,7 +425,7 @@ read any flash messages from the session: {# ...or you can read and display every flash message available #} {% for label, messages in app.flashes %} {% for message in messages %} -
+
{{ message }}
{% 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 3026fd9224e..66a5136ddb4 100644 --- a/quick_tour/the_controller.rst +++ b/quick_tour/the_controller.rst @@ -337,6 +337,10 @@ And you can display the flash message in the template like this:
{% 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 e19498184cf..b76ee22a4cb 100644 --- a/session/avoid_session_start.rst +++ b/session/avoid_session_start.rst @@ -36,3 +36,7 @@ access the flash messages:
{% 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`. From 88614ad2c6f86e59b8128a29c36856ba0659704e Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Sat, 25 Mar 2017 16:40:52 +0100 Subject: [PATCH 3/4] =?UTF-8?q?It=20is=20not=20markdown,=20se=C3=B1or=20Ri?= =?UTF-8?q?cardo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.rst | 4 ++-- quick_tour/the_controller.rst | 4 ++-- session/avoid_session_start.rst | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controller.rst b/controller.rst index fd94523aa8e..9cff1e670e9 100644 --- a/controller.rst +++ b/controller.rst @@ -452,8 +452,8 @@ 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`. + The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3 + you had to use ``app.session.flashBag``. .. note:: diff --git a/quick_tour/the_controller.rst b/quick_tour/the_controller.rst index 66a5136ddb4..eab009aa038 100644 --- a/quick_tour/the_controller.rst +++ b/quick_tour/the_controller.rst @@ -338,8 +338,8 @@ And you can display the flash message in the template like this: {% 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`. + 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 b76ee22a4cb..4dd53ec5b78 100644 --- a/session/avoid_session_start.rst +++ b/session/avoid_session_start.rst @@ -38,5 +38,5 @@ access the flash messages: {% 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`. + The ``app.flashes()`` method was introduced in Symfony 3.3. Prior to version 3.3 + you had to use ``app.session.flashBag``. From c2b9c858711bff3aceffeec57b7580f3741a7fa6 Mon Sep 17 00:00:00 2001 From: Ricardo de Vries Date: Sun, 26 Mar 2017 11:25:28 +0200 Subject: [PATCH 4/4] Adjusted text from review @wouterj. --- controller.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller.rst b/controller.rst index 9cff1e670e9..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::