質問

I want to register my listener for kernel.request after Session listener has already fired but Router listener hasn't (so that in my listener I can already use the session, but in case the route is not found it is fired nonetheless). I read that it's possible to manipulate the order in which listeners fire by setting priority, however it seems that those 'standard' Symfony listeners all fire with default priority.

So is there any way / how can I register listeners between those provided by Symfony?

役に立ちましたか?

解決

You can gain acces to the priorities of listener in this way:

 php app/console container:debug listener_service_name

You should get a detailed output and under tags you can see the priority if it a kernel.event_listener. If it's a kernel.event_subscriber you have to look in the corresponding class into the getSubscribedEvents() method. The second array parameter is the priority.

他のヒント

By trial and error I discovered that RouterListener has priority of 31 or 32, and SessionListener has priority of 127 or 128. Therefore if I use any priority from 32 to 127 inclusively, I'll get my listener run between these two.

Now I wonder if there's any way to dump priorities of listeners or look them up.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top