Skip to content

[HttpFoundation] custom attribute/flash bag registration #41443

Closed
@kbond

Description

@kbond

Description
With the deprecation of the session service, I'm trying to figure out how to register custom attribute/flash bags (via SessionInterface::registerBag()) in 5.3+.

I'm not sure if this is the best practice but the common way of doing this pre-5.3 seems to be a compiler pass with the following:

$container->getDefinition('session')
    ->addMethodCall('registerBag', [new Reference('my_custom_bag_service')])
;

I thought about a request listener to run right after the SessionListener (to ensure the session isn't yet started) but that would trigger the Request::$session callback perhaps unnecessarily...

If there is currently a better way that works in 5.3, I can add this to the docs.

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