From 43ebae14ff1ccadf9e236a5e6ea4a41c463be564 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 17 Jan 2012 01:53:13 +0100 Subject: [PATCH] Reset parsers, visitors, filters, tests, functions when a new one or new extension is added --- lib/Twig/Environment.php | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index c026687..4f5fbca 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -617,6 +617,12 @@ class Twig_Environment public function addExtension(Twig_ExtensionInterface $extension) { $this->extensions[$extension->getName()] = $extension; + $this->parsers = null; + $this->visitors = null; + $this->filters = null; + $this->tests = null; + $this->functions = null; + $this->globals = null; } /** @@ -627,6 +633,12 @@ class Twig_Environment public function removeExtension($name) { unset($this->extensions[$name]); + $this->parsers = null; + $this->visitors = null; + $this->filters = null; + $this->tests = null; + $this->functions = null; + $this->globals = null; } /** @@ -659,6 +671,7 @@ class Twig_Environment public function addTokenParser(Twig_TokenParserInterface $parser) { $this->staging['token_parsers'][] = $parser; + $this->parsers = null; } /** @@ -721,6 +734,7 @@ class Twig_Environment public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) { $this->staging['visitors'][] = $visitor; + $this->visitors = null; } /** @@ -749,6 +763,7 @@ class Twig_Environment public function addFilter($name, Twig_FilterInterface $filter) { $this->staging['filters'][$name] = $filter; + $this->filters = null; } /** @@ -828,6 +843,7 @@ class Twig_Environment public function addTest($name, Twig_TestInterface $test) { $this->staging['tests'][$name] = $test; + $this->tests = null; } /** @@ -856,6 +872,7 @@ class Twig_Environment public function addFunction($name, Twig_FunctionInterface $function) { $this->staging['functions'][$name] = $function; + $this->functions = null; } /** -- 1.7.2.5