*/
public function setTemplate($name, $template)
{
- $this->templates[$name] = $template;
+ $this->templates[(string) $name] = $template;
}
/**
*/
public function getSource($name)
{
+ $name = (string) $name;
if (!isset($this->templates[$name])) {
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
}
*/
public function getCacheKey($name)
{
+ $name = (string) $name;
if (!isset($this->templates[$name])) {
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
}
*/
public function isFresh($name, $time)
{
+ $name = (string) $name;
if (!isset($this->templates[$name])) {
throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
}
$loader->isFresh('foo', time());
}
+
+ public function testTemplateReference()
+ {
+ $name = new Twig_Test_Loader_TemplateReference('foo');
+ $loader = new Twig_Loader_Array(array('foo' => 'bar'));
+
+ $loader->getCacheKey($name);
+ $loader->getSource($name);
+ $loader->isFresh($name, time());
+ $loader->setTemplate($name, 'foobar');
+ }
+}
+
+class Twig_Test_Loader_TemplateReference
+{
+ private $name;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ public function __toString()
+ {
+ return $this->name;
+ }
}