Skip to content

We cannot access to the getFlashBag with SessionInterface #15154

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 1 commit into from

Conversation

kdefarge
Copy link

I propose to use FlashBagInterface

I propose to use FlashBagInterface
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

It is correct that SessionInterface does not implement getFlashBag

Thank you. What a great first PR!

@yceruto
Copy link
Member

yceruto commented Mar 29, 2021

It's true, but the service related to FlashBagInterface is being deprecated since 5.1. Thus, I think we shouldn't encourage this practice.

@javiereguiluz
Copy link
Member

I'm a bit lost ... what should we do here? Inject RequestStack and do getSession() and getFlashBag() even if it's not part of the interface?

@wouterj
Copy link
Member

wouterj commented Dec 24, 2021

Hi!

What @javiereguiluz says is indeed the current way to get the flash bag. See symfony/symfony#5568 (comment) for a bit more background on why SessionInterface does not include getFlashBag().

I see that we fixed the code example by not using SessionInterface injection in 5.3 (https://symfony.com/doc/5.3/security/access_denied_handler#customize-the-unauthorized-response) and 5.2 is no longer maintained. So I we can safely close this PR.

Thanks for proposing this change however, @kdefarge. I'm sorry for the long wait here

@wouterj wouterj closed this Dec 24, 2021
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.

6 participants