Ver Fonte

[HttpKernel] removed the need to keep the compiled classes in the container

Fabien Potencier há 14 anos atrás
pai
commit
eb7c86b7a8

+ 9 - 1
src/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php

@@ -14,6 +14,7 @@ namespace Symfony\Component\HttpKernel\DependencyInjection;
 use Symfony\Component\DependencyInjection\ContainerBuilder;
 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
 use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\HttpKernel\Kernel;
 
 /**
  * Sets the classes to compile in the cache for the container.
@@ -22,6 +23,13 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
  */
 class AddClassesToCachePass implements CompilerPassInterface
 {
+    private $kernel;
+
+    public function __construct(Kernel $kernel)
+    {
+        $this->kernel = $kernel;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -34,6 +42,6 @@ class AddClassesToCachePass implements CompilerPassInterface
             }
         }
 
-        $container->setParameter('kernel.compiled_classes', array_unique($classes));
+        $this->kernel->setClassCache($container->getParameterBag()->resolveValue(array_unique($classes)));
     }
 }

+ 8 - 3
src/Symfony/Component/HttpKernel/Kernel.php

@@ -20,7 +20,6 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
 use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
-use Symfony\Component\DependencyInjection\Compiler\PassConfig;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
@@ -402,6 +401,14 @@ abstract class Kernel implements KernelInterface
         }
     }
 
+    /**
+     * Used internally.
+     */
+    public function setClassCache(array $classes)
+    {
+        file_put_contents($this->getCacheDir().'/classes.map', sprintf('<?php return %s;', var_export($classes, true)));
+    }
+
     /**
      * Gets the request start time (not available if debug is disabled).
      *
@@ -641,8 +648,6 @@ abstract class Kernel implements KernelInterface
         $container->addCompilerPass(new AddClassesToCachePass($this));
         $container->compile();
 
-        file_put_contents($this->getCacheDir().'/classes.map', sprintf('<?php return %s;', var_export($container->getParameter('kernel.compiled_classes'), true)));
-
         return $container;
     }