Symfony 2 - UrlGenerator::doGenerate is called before listener
Posted
by
guyaloni
on Stack Overflow
See other posts from Stack Overflow
or by guyaloni
Published on 2011-11-16T13:12:22Z
Indexed on
2012/06/18
9:16 UTC
Read the original article
Hit count: 227
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???
© Stack Overflow or respective owner