Explorar el Código

[FrameworkBundle] Taking advantage of the known type of $template to render meaningfull information about the template

The $template variable is not type-hinted, but this is just because the `locate` method must follow the signature of the interface.
According to the PHPDoc, the $template variable is in fact an instance of TemplateReferenceInterface, meaning we can call getPath()
on it. The previous method of json_encode just returned two empty braces, at least in my experience.
Ryan Weaver hace 14 años
padre
commit
5ecf1cd1d1

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php

@@ -60,7 +60,7 @@ class TemplateLocator implements FileLocatorInterface
         try {
             return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path);
         } catch (\InvalidArgumentException $e) {
-            throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', json_encode($template), $this->path), 0, $e);
+            throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template->getPath(), $this->path), 0, $e);
         }
     }
 }