From: Markus Bachmann Date: Tue, 18 Dec 2012 09:57:02 +0000 (+0100) Subject: Fix the registration of simple filters, test and functions X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a311fe00177fa40b67314fa2aba7da04667d9711;p=web%2Fkonrad%2Ftwig.git Fix the registration of simple filters, test and functions --- diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 543111b..9958573 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -761,6 +761,11 @@ class Twig_Environment throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter'); } + if ($name instanceof Twig_SimpleFilter) { + $filter = $name; + $name = $filter->getName(); + } + $this->staging->addFilter($name, $filter); } @@ -845,6 +850,11 @@ class Twig_Environment throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest'); } + if ($name instanceof Twig_SimpleTest) { + $test = $name; + $name = $test->getName(); + } + $this->staging->addTest($name, $test); } @@ -878,6 +888,11 @@ class Twig_Environment throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction'); } + if ($name instanceof Twig_SimpleFunction) { + $function = $name; + $name = $function->getName(); + } + $this->staging->addFunction($name, $function); }