deblan.tv/vendor/trinity/src/Trinity/Bundle/VarsEditorBundle/Twig/Extension/GlobalVarsExtension.php
2015-09-14 14:53:34 +02:00

34 lines
808 B
PHP

<?php
namespace Trinity\Bundle\VarsEditorBundle\Twig\Extension;
use Symfony\Component\DependencyInjection\Container;
class GlobalVarsExtension extends \Twig_Extension
{
protected $container;
public function __construct(Container $container)
{
$this->container = $container;
}
public function getFunctions()
{
return array(
'global_var' => new \Twig_Function_Method($this, 'getGlobalVarValue'),
'get_var' => new \Twig_Function_Method($this, 'getGlobalVarValue'),
);
}
public function getGlobalVarValue($key, $default = null, $locale = null)
{
return $this->container->get('global_vars')->get($key, $default, $locale);
}
public function getName()
{
return 'global_var_extension';
}
}