diff --git a/composer.json b/composer.json index d1e9288..4f9f0ce 100644 --- a/composer.json +++ b/composer.json @@ -26,5 +26,6 @@ }, "autoload": { "psr-0": { "TwigGenerator": "src/" } - } + }, + "minimum-stability": "dev" } diff --git a/src/TwigGenerator/Builder/BaseBuilder.php b/src/TwigGenerator/Builder/BaseBuilder.php index 2a9755d..30b77eb 100644 --- a/src/TwigGenerator/Builder/BaseBuilder.php +++ b/src/TwigGenerator/Builder/BaseBuilder.php @@ -324,7 +324,14 @@ protected function loadTwigFilters(\Twig_Environment $twig) { foreach ($this->twigFilters as $twigFilter) { if (is_object($twigFilter)) { - $twig->addFilter($twigFilter); + if (method_exists($twigFilter, 'getName')) { + $twig->addFilter($twigFilter); + } else { + $filter = new \ReflectionObject($twigFilter); + $name = $filter->getProperty('method'); + $name->setAccessible(true); + $twig->addFilter($name->getValue($twigFilter), $twigFilter); + } continue; } elseif (($pos = strpos($twigFilter, ':')) !== false) { $twigFilterName = substr($twigFilter, $pos + 2);