0

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???

2 Answers 2

2

Have you tried manipulating the priority option?

tags:
   - { name: kernel.event_listener, event: kernel.request, priority: 0, method: onKernelRequest }
3
  • Just did, it doesn't help - still get the same exception.
    – guyaloni
    Nov 17, 2011 at 8:35
  • Ok, with priority: 100000 it works, I guess it is possible to have a lower priority and it will still work. I tried to print some debugging messages from my listener and from the UrlGenerator, but find it quite hard to follow. Anyway, now it works, thanks!
    – guyaloni
    Nov 18, 2011 at 11:35
  • Actually I have just checked... very wiered. When I give priority: 64, it works fine. When I give it 63, it simply skip the login panel and shows the protected page. Don't understand it...
    – guyaloni
    Nov 18, 2011 at 12:06
0

Yep, you should use priority option it can be from -255 to 255

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.