Tuan-Tu
Tuan-Tu

Reputation: 73

How to use AutoExpireFlashBag in Symfony?

With my current configuration, inside a controller $this->getRequest()->getSession()->getFlashBag() always returns a FlashBag instance.

I see in the documentation that there is an AutoExpireFlashBag class that automatically expires messages, whether consumed or not.

How do I get Symfony to use that class instead of the regular FlashBag class ?

Thanks!

Upvotes: 2

Views: 848

Answers (1)

Michael Sivolobov
Michael Sivolobov

Reputation: 13340

It is set by a global parameter in config file. You need just rename class for flashbag in session.flashbag.class parameter. It is defined in https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml#L9. But you can override it in your configs.

Upvotes: 3

Related Questions