Kaynağa Gözat

[TwigBundle] Fix the cache warmer

Victor Berchet 14 yıl önce
ebeveyn
işleme
87000a163b

+ 1 - 4
src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php

@@ -60,9 +60,6 @@ class TemplateCacheCacheWarmer extends CacheWarmer
             foreach ($this->findTemplatesIn($bundle->getPath().'/Resources/views', $name) as $template) {
                 $twig->loadTemplate($template);
             }
-            foreach ($this->findTemplatesIn($this->rootDir.'/'.$name.'/views', $name) as $template) {
-                $twig->loadTemplate($template);
-            }
         }
 
         foreach ($this->findTemplatesIn($this->rootDir.'/views') as $template) {
@@ -100,7 +97,7 @@ class TemplateCacheCacheWarmer extends CacheWarmer
                     if (null !== $bundle) {
                       $template->set('bundle', $bundle);
                     }
-                    $templates[] = $template;
+                    $templates[] = $template->getLogicalName();
                 }
             }
         }

+ 9 - 3
src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

@@ -76,12 +76,18 @@ class FilesystemLoader implements \Twig_LoaderInterface
         return filemtime($this->findTemplate($name)) < $time;
     }
 
+    /**
+     * Returns the path to the template file
+     *
+     * @param $name The template logical name
+     *
+     * @return string The path to the template file
+     */
     protected function findTemplate($name)
     {
-        $tpl = ($name instanceof TemplateReferenceInterface) ? $name : $this->parser->parse($name);
+        $tpl = $this->parser->parse($name);
 
-        $key = $tpl->getSignature();
-        if (isset($this->cache[$key])) {
+        if (isset($this->cache[$key = $tpl->getSignature()])) {
             return $this->cache[$key];
         }