symfony - Symfony2 bundle specific Twig configuration/variables -


I know that I can set the tweak variable in my app / config / config.yml Yes, although I want to set the variable at the bundle level (Example: Bundle / Resources / Config / Yml ).

For example, I want to include a bundle version identifier in the footer of my pages I tried to keep 'toggle config' in my bundles' services.yml but Symphony was not able to parse the configuration.

How can I get it?

I'm not sure how you can implement bundle specific configuration for your example Configure bundles Main config files are imported, which are now environment specific rather than specific bundles.

However, for your example I can only create a jogging extension that gives you the name of the bundle, in this way you can use it in your templates wherever you like. You can get your controller's fully designated route by request, then use only the pre-match to get the name of the bundle. Something like the following should be done:

  public function getBundleName () {$ pattern = "# ([a-zA-Z] *) bundle #"; $ Matches = array (); Preg_match ($ Pattern, $ this-> Get Container-> (Receive 'Request') -> Get ('_ Controller'), $ matches); Returns $ matches [1]; }   

To be an example of the container in this example, $ this-> The container is set in the constructor if you are using another method to get the controller, then replace it accordingly.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -