From 2ae542748a8065aba925b44b99755010dbf12ac9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 5 Feb 2011 01:17:59 +0100 Subject: [PATCH] [TwigBundle] made error message more explicit --- .../Bundle/TwigBundle/Loader/FilesystemLoader.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index a2515834a5e4..6700be1ae6dd 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -75,11 +75,9 @@ public function isFresh($name, $time) protected function findTemplate($name) { - if (!is_array($name)) { - $name = $this->parser->parse($name); - } + $tpl = is_array($name) ? $name : $this->parser->parse($name); - $key = md5(serialize($name)); + $key = md5(serialize($tpl)); if (isset($this->cache[$key])) { return $this->cache[$key]; } @@ -87,13 +85,13 @@ protected function findTemplate($name) $file = null; $previous = null; try { - $file = $this->locator->locate($name); + $file = $this->locator->locate($tpl); } catch (\InvalidArgumentException $e) { $previous = $e; } if (false === $file || null === $file) { - throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $name), 0, null, $previous); + throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', json_encode($name)), 0, null, $previous); } return $this->cache[$key] = $file;