简体   繁体   中英

Twig extension - symfony2 environment

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM