I need to run some code, for example, to detect browser prefered languages and set locale accordingly with available languages in my app and other things like that. This code will live inside a core bundle of my own.
I’m wondering where is the best place for this kind of code, let’s say a sort of controller action that must run before any other.
I guess that making an include to the same file in both app.php and app_dev.php is a bad workaround, especially upon Symfony upgrades.
I can’t find any answer in the docs nor on the web at the moment.
Create a listener for an event. In most cases,
kernel.requestis what you need to listen for. I put listener classes into theListenernamespace of a bundle.