Skip to content
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

[FrameworkBundle] Deprecate flashbag and attributebag services #13467

Closed
fabpot opened this issue Apr 1, 2020 · 4 comments · Fixed by #13477
Closed

[FrameworkBundle] Deprecate flashbag and attributebag services #13467

fabpot opened this issue Apr 1, 2020 · 4 comments · Fixed by #13477
Labels
hasPR A Pull Request has already been submitted for this issue. HttpFoundation
Milestone

Comments

@fabpot
Copy link
Member

fabpot commented Apr 1, 2020

Q A
Feature PR symfony/symfony#36273
PR author(s) @william Arslett
Merged in 5.1-dev
@javiereguiluz
Copy link
Member

@warslett I've found a single occurrence of these deprecated services in the Symfony Docs. It's this example about "namespaced session attributes":

.. code-block:: yaml

    # config/services.yaml
    session:
        public: true
        class: Symfony\Component\HttpFoundation\Session\Session
        arguments: ['@session.storage', '@session.namespacedattributebag', '@session.flash_bag']

    session.namespacedattributebag:
        class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag

How could we remove the '@session.flash_bag' service in this config? Thanks.

@warslett
Copy link

warslett commented Apr 1, 2020

@javiereguiluz I will test this to be sure but in theory you don't need to inject a flashbag. If you want to use the default flashbag, you just set the flashbag parameter to null. The deprecated flashbag service uses session as a factory so it will always be the flashbag contained in the session. I'd suggest this as the recommended approach for injecting NamespacedAttributeBag:

# config/services.yaml
    session:
        public: true
        class: Symfony\Component\HttpFoundation\Session\Session
        arguments: ['@session.storage', '@session.namespacedattributebag', ~]

    session.namespacedattributebag:
        class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag

EDIT: Updated muddled wording

@warslett
Copy link

warslett commented Apr 1, 2020

or even just:

# config/services.yaml
    session:
        public: true
        class: Symfony\Component\HttpFoundation\Session\Session
        arguments: ['@session.storage', '@session.namespacedattributebag']

    session.namespacedattributebag:
        class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag

@javiereguiluz
Copy link
Member

@warslett thanks a lot for double checking this! We've created a pull request to fix this. Thanks!

@xabbuh xabbuh added the hasPR A Pull Request has already been submitted for this issue. label Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. HttpFoundation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants