Skip to content

Adding warning about depending on concrete implementation of Session #13884

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 rely on :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
If you want avoid depending on concrete implementation of `Session` and rely 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
you will find your self in a situation that `getFlashBag` is not declared in an interface.
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`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In order fix this "problem" you must inject `FlashBagInterface`/`session.flash_bag` and relay on `FlashBagInterface`
In order fix this "problem" you must inject ``FlashBagInterface``/``session.flash_bag`` and relay on ``FlashBagInterface``

instead of `Session` for access to "Flash Messages"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
instead of `Session` for access to "Flash Messages"
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()``:

Expand Down