symfony - Symfony2 bundle specific Twig configuration/variables -
I know that I can set the tweak variable in my 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' 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: To be an example of the container in this example, app / config / config.yml Yes, although I want to set the variable at the bundle level (Example:
Bundle / Resources / Config / Yml ).
services.yml but Symphony was not able to parse the configuration.
public function getBundleName () {$ pattern = "# ([a-zA-Z] *) bundle #"; $ Matches = array (); Preg_match ($ Pattern, $ this-> Get Container-> (Receive 'Request') -> Get ('_ Controller'), $ matches); Returns $ matches [1]; }
$ this-> The container is set in the constructor if you are using another method to get the controller, then replace it accordingly.
Comments
Post a Comment