From b721f043cdaef492e4eae1832ff7af5287fb89de Mon Sep 17 00:00:00 2001 From: fabien Date: Wed, 11 Nov 2009 16:55:35 +0000 Subject: [PATCH] renamed getTemplateName to getTemplateClass git-svn-id: http://svn.twig-project.org/trunk@131 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- lib/Twig/Compiler.php | 4 ++-- lib/Twig/Loader.php | 11 +++++++++-- lib/Twig/LoaderInterface.php | 9 +++++++++ lib/Twig/Node/Import.php | 4 ++-- lib/Twig/Node/Module.php | 6 +++--- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/Twig/Compiler.php b/lib/Twig/Compiler.php index 936c5f5..8604a6a 100644 --- a/lib/Twig/Compiler.php +++ b/lib/Twig/Compiler.php @@ -244,8 +244,8 @@ class Twig_Compiler implements Twig_CompilerInterface return $this->env; } - public function getTemplateName($name) + public function getTemplateClass($name) { - return $this->getEnvironment()->getLoader()->getTemplateName($name); + return $this->getEnvironment()->getLoader()->getTemplateClass($name); } } diff --git a/lib/Twig/Loader.php b/lib/Twig/Loader.php index 61e8276..2dc0cd3 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->getTemplateName($name); + $cls = $this->getTemplateClass($name); if (class_exists($cls, false)) { @@ -127,7 +127,14 @@ abstract class Twig_Loader implements Twig_LoaderInterface $this->env = $env; } - public function getTemplateName($name) + /** + * 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); } diff --git a/lib/Twig/LoaderInterface.php b/lib/Twig/LoaderInterface.php index 4682f08..cd44e32 100644 --- a/lib/Twig/LoaderInterface.php +++ b/lib/Twig/LoaderInterface.php @@ -33,4 +33,13 @@ 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); } diff --git a/lib/Twig/Node/Import.php b/lib/Twig/Node/Import.php index 2614084..d5ef05c 100644 --- a/lib/Twig/Node/Import.php +++ b/lib/Twig/Node/Import.php @@ -41,7 +41,7 @@ class Twig_Node_Import extends Twig_Node ->string($this->macro) ->raw(");\n\n") ->write("if (!class_exists(") - ->string($compiler->getTemplateName($this->macro).'_Macro') + ->string($compiler->getTemplateClass($this->macro).'_Macro') ->raw("))\n") ->write("{\n") ->indent() @@ -50,7 +50,7 @@ class Twig_Node_Import extends Twig_Node ->write("}\n") ->write(sprintf("\$context[")) ->string($this->var) - ->raw(sprintf("] = new %s_Macro(\$this->env);\n", $compiler->getTemplateName($this->macro))) + ->raw(sprintf("] = new %s_Macro(\$this->env);\n", $compiler->getTemplateClass($this->macro))) ; } diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 36adfc5..99a8765 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -107,10 +107,10 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface $compiler ->write("/* $this->filename */\n") - ->write('class '.$compiler->getTemplateName($this->filename)) + ->write('class '.$compiler->getTemplateClass($this->filename)) ; - $parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : $compiler->getTemplateName($this->extends); + $parent = null === $this->extends ? $compiler->getEnvironment()->getBaseTemplateClass() : $compiler->getTemplateClass($this->extends); $compiler ->raw(" extends $parent\n") @@ -206,7 +206,7 @@ class Twig_Node_Module extends Twig_Node implements Twig_NodeListInterface $compiler ->write("\n") - ->write('class '.$compiler->getTemplateName($this->filename).'_Macro extends Twig_Macro'."\n") + ->write('class '.$compiler->getTemplateClass($this->filename).'_Macro extends Twig_Macro'."\n") ->write("{\n") ->indent() ; -- 1.7.2.5