New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the "ea" global variable dynamic #6273
base: 4.x
Are you sure you want to change the base?
Conversation
b987fd8
to
1bb12d3
Compare
This could definitely be a solution that could work for us 🙏 Nicolas, thanks a lot for working on this. I'm going to test and look into this very soon! You've probably seen it but ... in twigphp/Twig#4007 some people are reporting that they face a similar issue but when using Shopware instead of EasyAdmin. I don't know if there's a way to solve this at Twig level for all projects, but I just wanted to mention it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
e551e0d
to
1bb12d3
Compare
1bb12d3
to
eee7e0a
Compare
I tried relying on __call but that breaks the CI so I reverted to listing methods explicitly. About shopware/etc. I suppose they do the same mistake. A better option would be to deprecate the global and replace it with a function. This PR gives a hook to do so. My TL;DR is: don't use globals for non-static values. |
this will still break if templates do things like |
True, and there is no way around this so we have to go with it IMHO. |
Is this PR also fixing this issue with another approach? |
Both should be merged, and a deprecation should be added here. Note that the getGlobals() method should be deprecated soon in twig. |
My tentative fix for #5986