Ver Fonte

Merge remote branch 'vicb/twig_warmer'

* vicb/twig_warmer:
  [TwigBundle] Update the cache warmer
Fabien Potencier há 14 anos atrás
pai
commit
dd150fc478

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

@@ -25,8 +25,6 @@ use Symfony\Component\Finder\Finder;
  */
 class TemplateCacheCacheWarmer extends CacheWarmer
 {
-    const TEMPLATES_PATH_IN_BUNDLE = '/Resources/views';
-
     protected $container;
     protected $parser;
     protected $kernel;
@@ -59,12 +57,15 @@ class TemplateCacheCacheWarmer extends CacheWarmer
         $twig = $this->container->get('twig');
 
         foreach ($this->kernel->getBundles() as $name => $bundle) {
-            foreach ($this->findTemplatesIn($bundle->getPath().self::TEMPLATES_PATH_IN_BUNDLE, $name) as $template) {
+            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) as $template) {
+        foreach ($this->findTemplatesIn($this->rootDir.'/views') as $template) {
             $twig->loadTemplate($template);
         }
     }

+ 1 - 1
src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

@@ -19,7 +19,7 @@
 
         <service id="twig.cache_warmer" class="%twig.cache_warmer.class%" public="false">
             <argument type="service" id="service_container" />
-            <argument>%kernel.root_dir%/views</argument>
+            <argument>%kernel.root_dir%/Resources</argument>
         </service>
 
         <service id="twig.loader" class="%twig.loader.class%">