Skip to content

[Session] "getFlashBag" interfacing issue #11279

Closed
@linaori

Description

@linaori

When you want the FlashBag to set a message, you'd like to do getFlashBag on the session. However, you can only achieve this by type hinting an injection on the Session\Session object. The Session\SessionInterface doesn't contain the "getFlashBag" method thus you can't use the Request::getSession();

If you do want to get the flash bag from it, you can try "getSession()->getBag('flash bag name')". However, that doesn't guarantee that you get the flash bag that was inserted because you don't know the name.

It's a minor inconvenience that has multiple custom solutions, but I've seen this issue come around a couple of times already in "#symfony".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions