return $this->env;
}
- public function getTemplateName($name)
+ public function getTemplateClass($name)
{
- return $this->getEnvironment()->getLoader()->getTemplateName($name);
+ return $this->getEnvironment()->getLoader()->getTemplateClass($name);
}
}
*/
public function load($name)
{
- $cls = $this->getTemplateName($name);
+ $cls = $this->getTemplateClass($name);
if (class_exists($cls, false))
{
$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);
}
* @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);
}
->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()
->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)))
;
}
$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")
$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()
;