Reputation: 1211
http://symfony.com/doc/current/templating/twig_extension.html
Documentation mentiones that I can define global variables.
But \Twig_Extension
does not seems to have method that I can override in order to create global variables.
Does anybody knows how can I create global variable using the Twig extension?
Upvotes: 3
Views: 4100
Reputation: 15638
The getGlobals
function was deprecated, if you really want to re-enable this feature you have to implement from the interface Twig_Extension_GlobalsInterface
as well,
class MyTwigExtensions extends \Twig_Extension implements \Twig_Extension_GlobalsInterface {
public function getGlobals() {
//...
}
public function getName() {
return 'MyTwigExtensions';
}
}
Upvotes: 5