Twig extension - symfony2 environment

2019-09-12 04:43发布

问题:

im trying to write an extension that works will depend on the environment. How to retrieve the name of the current environment inside the extension class? What is best practices?

回答1:

You'll have to inject the parameter in your extension constructor.

Either, you may refer to current envinroment in twig templates as app.environment.



标签: php symfony twig