I'm trying to add a Symfony2 login event listener, the goal is to set a database-stored locale if the user is logged, on each request, and to fallback to a default one of there is no user logged. I use FOSUserBundle, and I'm trying to get the security.interactive_login event to work. I find a lot of code over the internet like this one: http://dev.dbl-a.com/symfony-2-0/how-to-add-a-symfony2-login-event-listener/
I have my own child bundle of the FOSUserBundle and this implementation in services.yml:
my_user.security.interactive_login_listener:
class: My\UserBundle\EventListener\UserListener
arguments: [@security.context, @doctrine]
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: setLocaleForAuthenticatedUser }
my_user.security.kernel_request_listener:
class: My\UserBundle\EventListener\UserListener
arguments: [@security.context, @doctrine]
tags:
- { name: kernel.event_listener, event: kernel.request, method: setLocaleForUnauthenticatedUser }
Problem is, the security.interactive_login event is never triggered, even when logging, even when logged. On the contrary, my setLocaleForUnauthenticatedUser is always trigered. Every code sample I found seems to work fluenty, what's wrong with my app?