mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Fix the registration of simple filters, test and functions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user