From 3d622e472e9f2a16f54750e8cfccf3938bef53b5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Thu, 30 Sep 2010 10:10:34 +0200 Subject: [PATCH] added the environment as an argument to initRuntime --- lib/Twig/Environment.php | 6 +++--- lib/Twig/Extension.php | 4 +++- lib/Twig/ExtensionInterface.php | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index d25ff7f..4b91a34 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -208,8 +208,6 @@ class Twig_Environment if (!$this->runtimeInitialized) { $this->initRuntime(); - - $this->runtimeInitialized = true; } return $this->loadedTemplates[$cls] = new $cls($this); @@ -295,8 +293,10 @@ class Twig_Environment public function initRuntime() { + $this->runtimeInitialized = true; + foreach ($this->getExtensions() as $extension) { - $extension->initRuntime(); + $extension->initRuntime($this); } } diff --git a/lib/Twig/Extension.php b/lib/Twig/Extension.php index 0a99675..dc1d34a 100644 --- a/lib/Twig/Extension.php +++ b/lib/Twig/Extension.php @@ -14,8 +14,10 @@ abstract class Twig_Extension implements Twig_ExtensionInterface * Initializes the runtime environment. * * This is where you can load some file that contains filter functions for instance. + * + * @param Twig_Environment $environement The current Twig_Environment instance */ - public function initRuntime() + public function initRuntime(Twig_Environment $environement) { } diff --git a/lib/Twig/ExtensionInterface.php b/lib/Twig/ExtensionInterface.php index de4f684..38ad900 100644 --- a/lib/Twig/ExtensionInterface.php +++ b/lib/Twig/ExtensionInterface.php @@ -22,8 +22,10 @@ interface Twig_ExtensionInterface * Initializes the runtime environment. * * This is where you can load some file that contains filter functions for instance. + * + * @param Twig_Environment $environement The current Twig_Environment instance */ - public function initRuntime(); + public function initRuntime(Twig_Environment $environement); /** * Returns the token parser instances to add to the existing list. -- 1.7.2.5