fabpot/Twig — Issue #479: Filters in Twig_Extension do not work
Author: Markkaz
Created: 2011-10-21 19:30:34+00:00
State: open

I made my own Twig_Extension class in order to add some filters and functions to Twig. This class looks like this:
```php
class TwigExtension extends \Twig_Extension
{
public function getName()
{
return 'webdevils';
}

public function getFunctions()
{
return array(
'runAction' => new \Twig_Function_Method($this, 'runAction'),
'page_range' => new \Twig_Function_Function('\scratchframework\core\TwigFunctions::page_range'),
'time' => new \Twig_Function_Function('\time'),
'avatar' => new \Twig_Function_Method($this, 'avatar')
);
}

public function getFilters()
{
return array(
'years_ago' => new \Twig_Filter_Function('\scratchframework\core\TwigFilters::yearsAgo')
);
}
}
```
The functions work fine, but the filters are not loaded. I also experimented somewhat by added die('boe!!!') statements in the getFunctions() and getFilters() method. Strangely the die() function is not executed in the getFilters() method.