Prechádzať zdrojové kódy

[FrameworkBundle] tweak Templating

Victor Berchet 14 rokov pred
rodič
commit
5eee0db18e

+ 4 - 6
src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php

@@ -35,12 +35,14 @@ class TemplatePathsCacheWarmer extends CacheWarmer
      *
      * @param KernelInterface      $kernel  A KernelInterface instance
      * @param FileLocatorInterface $locator A FileLocatorInterface instance
+     * @param TemplateNameParser   $parser  A TemplateNameParser instance
      * @param string               $rootDir The directory where global templates can be stored
      */
-    public function __construct(KernelInterface $kernel, FileLocatorInterface $locator, $rootDir)
+    public function __construct(KernelInterface $kernel, FileLocatorInterface $locator, TemplateNameParser $parser, $rootDir)
     {
         $this->kernel = $kernel;
         $this->locator = $locator;
+        $this->parser = $parser;
         $this->rootDir = $rootDir;
     }
 
@@ -97,11 +99,7 @@ class TemplatePathsCacheWarmer extends CacheWarmer
     }
 
     protected function parseTemplateName($file, $prefix, $bundle = '')
-    {
-        if (null === $this->parser) {
-            $this->parser = $this->kernel->getContainer()->get('templating.name_parser');
-        }
-        
+    {      
         $prefix = strtr($prefix, '\\', '/');
         $path = strtr($file->getPathname(), '\\', '/');
 

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml

@@ -40,6 +40,7 @@
         <service id="templating.cache_warmer.template_paths" class="%templating.cache_warmer.template_paths.class%" public="false">
             <argument type="service" id="kernel" />
             <argument type="service" id="file_locator" />
+            <argument type="service" id="templating.name_parser" />
             <argument>%kernel.root_dir%/views</argument>
         </service>