dimanche 19 avril 2015

Symfony2 kernel.controller event for single controller or bundle scope

My question about a little, but significant detail that i discover while read this article: http://ift.tt/1no6Qg9


Manual says, that declared TokenListener will be executed on each request. So, if i have a big application with a lot of controllers (or bundles with own controllers), and a lot of any other kind of event listeners, this beaviour add an overhead: each of the event listeners will be executed in each request for each bundle! For example, i have default AppBundle and ApiBundle, and in given example, TokenListener executes in case of request to boths bundles, because defined in app specific config: app/config/services.yml


How to avoid this beaviour? How to define listeners only per bundle, or, better, per controller? Maybe,it can be defined in bundle specific services.yml, but this is also too wide scope for listener, that used in a few controllers.


Aucun commentaire:

Enregistrer un commentaire