From 475eae5fce8dc66ab7d5820971698ecbca8de3f1 Mon Sep 17 00:00:00 2001 From: fabien Date: Wed, 11 Nov 2009 16:57:23 +0000 Subject: [PATCH] moved getTemplateClass() to Twig_Environment git-svn-id: http://svn.twig-project.org/trunk@132 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- lib/Twig/Compiler.php | 2 +- lib/Twig/Environment.php | 12 ++++++++++++ lib/Twig/Loader.php | 14 +------------- lib/Twig/LoaderInterface.php | 9 --------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index 8604a6a..aba6004 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -246,6 +246,6 @@ class Twig_Compiler implements Twig_CompilerInterface public function getTemplateClass($name) { - return $this->getEnvironment()->getLoader()->getTemplateClass($name); + return $this->getEnvironment()->getTemplateClass($name); } } diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 98eb962..32414f4 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -78,6 +78,18 @@ class Twig_Environment $this->trimBlocks = (bool) $bool; } + /** + * Gets the template class associated with the given string. + * + * @param string $name The name for which to calculate the template class name + * + * @return string The template class name + */ + public function getTemplateClass($name) + { + return '__TwigTemplate_'.md5($name); + } + public function loadTemplate($name) { if (!$this->runtimeInitialized) diff --git a/lib/Twig/Loader.php b/lib/Twig/Loader.php index 2dc0cd3..2433d55 100644 --- a/lib/Twig/Loader.php +++ b/lib/Twig/Loader.php @@ -59,7 +59,7 @@ abstract class Twig_Loader implements Twig_LoaderInterface */ public function load($name) { - $cls = $this->getTemplateClass($name); + $cls = $this->env->getTemplateClass($name); if (class_exists($cls, false)) { @@ -127,18 +127,6 @@ abstract class Twig_Loader implements Twig_LoaderInterface $this->env = $env; } - /** - * Gets the template class associated with the given string. - * - * @param string $name The name for which to calculate the template class name - * - * @return string The template class name - */ - public function getTemplateClass($name) - { - return '__TwigTemplate_'.md5($name); - } - public function getCacheFilename($name) { return $this->cache.'/twig_'.md5($name).'.php'; diff --git a/lib/Twig/LoaderInterface.php b/lib/Twig/LoaderInterface.php index cd44e32..4682f08 100644 --- a/lib/Twig/LoaderInterface.php +++ b/lib/Twig/LoaderInterface.php @@ -33,13 +33,4 @@ interface Twig_LoaderInterface * @param Twig_Environment $env A Twig_Environment instance */ public function setEnvironment(Twig_Environment $env); - - /** - * Gets the template class associated with the given string. - * - * @param string $name The name for which to calculate the template class name - * - * @return string The template class name - */ - public function getTemplateClass($name); } -- 1.7.2.5