Symfony 2 - UrlGenerator::doGenerate is called before listener
- by guyaloni
I want to add to the context a parameter, so when login is called I can use it in the route (similar to _locale).
I can add this piece of code in HttpUtils.php (as resetLocale), but i don't find it very clean. The reason I need it is the firewall redirection to the login controller, which I would like to have in its route a customized parameter.
My problem is that my listener is called after UrlGenerator::doGenerate is called, so I get a MissingMandatoryParametersException.
Here is my config.yml relevant code:
services:
mycompany.demobundle.listener.request:
class: MyCompany\DemoBundle\RequestListener
arguments: [@router, @security.context]
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
Any idea???