symfony - Global values: Define as service or define abstract Controller class? -
In my Symfony2 app, I want to get a value from my database on every template and do not want to call Each controller I know that I can define it as a service and inject it into my jogging templates (defining it as a twig global).
Is this a common and recommended way? Or should I make an abstract controller class where I get that value in my constructor and then get it from all my other controllers?
Note: This is not really a stable value, which is similar to all users, but this is a user-specific value that is different for each user. If these variables were used to present the same place on your page If you go then you can present one. Like this: This will apply the entire output of your bundle / user controller / statistics to the #sidebardevice. Inside this action you can remove all the information you need. If you need to use these variables in another way, then you should check it out.
& lt; Div id = "sidebar" & gt; {{Render (Controller ('Your bundle: User: Statistics'))}}
Comments
Post a Comment