Thanks to visit codestin.com
Credit goes to github.com

Skip to content

#7676 - Flash messages #7684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

#7676 - Flash messages #7684

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Mar 25, 2017

This pull request fixes #7676 that documents the flash messages that are been changed in symfony/symfony#21819.

@linaori
Copy link
Contributor

linaori commented Mar 25, 2017

In the context of the text I have some remarks:

In the template of the next page (or even better, in your base layout template), read any flash messages from the session:
- controller.rst

For example, one common problem in this situation involves checking for flash messages, which are stored in the session. The following code would guarantee that a session is always started:
- avoid_session_start.rst

Minor details, but both of them are still referring to using the session, while the examples do not use the session directly anymore (no reference to app.session). Maybe those 2 pages could do with a note that this is a (new) shortcut?

@wouterj
Copy link
Member

wouterj commented Mar 25, 2017

Besides @iltar's comment, we should also add a versionadded directive after the code example:

.. versionadded:: 3.3
    The `app.flashes()` method was introduced in Symfony 3.3. Prior to version 3,3
    you had to use `app.app.session.flashBag`.

@wouterj
Copy link
Member

wouterj commented Mar 25, 2017

Status: needs work

@javiereguiluz
Copy link
Member

javiereguiluz commented Mar 25, 2017

We should also deprecate or refactorize or add a big warning message to this article: https://symfony.com/doc/current/session/avoid_session_start.html

@ghost
Copy link
Author

ghost commented Mar 25, 2017

@javiereguiluz I think we should deprecate it because your new method does not longer checks the session making that part of the documentation confusing and not longer needed.

controller.rst Outdated
@@ -451,6 +451,10 @@ read any flash messages from the session:
<?php endforeach ?>
<?php endforeach ?>

.. versionadded:: 3.3
The `app.flashes()` method was introduced in Symfony 3.3. Prior to version 3.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike Markdown, in RST files we need to use double-backticks for code:

``app.flashes()``

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj
Copy link
Member

wouterj commented Mar 25, 2017

hasPreviousSession() still can be use-full imo. So I would keep the article by adding a small .. tip:: saying that there is this new nice flashes() method that can be used instead. We can always update the example if we can come up with a better one in the future.

Regarding the text, I think we can leave the session bit in there and do something like: "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():" Not 100% sure though

@ghost
Copy link
Author

ghost commented Mar 26, 2017

By the thumbs up from @iltar I assumed the suggestion from @wouterj seems to be correct.

Regarding your hasPreviousSession() it is still useful but that makes these lines (source file) not needed imo. Should I replace them with the small .. tip:: Since Symfony 3.3 there is a better method to read the flash messages from the session. See controller.rst#flashmessages... something like that?

Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@xabbuh
Copy link
Member

xabbuh commented Apr 1, 2017

Thank you @Ricknox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved flash messages handling in Twig templates
7 participants