|
@@ -20,14 +20,18 @@ 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;
|
|
|
use Symfony\Component\HttpKernel\Config\FileLocator;
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
|
|
|
+use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass;
|
|
|
+use Symfony\Component\HttpKernel\DependencyInjection\Extension as DIExtension;
|
|
|
use Symfony\Component\Config\Loader\LoaderResolver;
|
|
|
use Symfony\Component\Config\Loader\DelegatingLoader;
|
|
|
use Symfony\Component\Config\ConfigCache;
|
|
|
+use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
|
|
|
|
|
/**
|
|
|
* The Kernel is the heart of the Symfony system.
|
|
@@ -47,6 +51,7 @@ abstract class Kernel implements KernelInterface
|
|
|
protected $booted;
|
|
|
protected $name;
|
|
|
protected $startTime;
|
|
|
+ protected $classes;
|
|
|
|
|
|
const VERSION = '2.0.0-DEV';
|
|
|
|
|
@@ -63,6 +68,7 @@ abstract class Kernel implements KernelInterface
|
|
|
$this->booted = false;
|
|
|
$this->rootDir = $this->getRootDir();
|
|
|
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
|
|
|
+ $this->classes = array();
|
|
|
|
|
|
if ($this->debug) {
|
|
|
ini_set('display_errors', 1);
|
|
@@ -332,6 +338,28 @@ abstract class Kernel implements KernelInterface
|
|
|
return $this->container;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Loads the PHP class cache.
|
|
|
+ *
|
|
|
+ * @param string $name The cache name prefix
|
|
|
+ * @param string $extension File extension of the resulting file
|
|
|
+ */
|
|
|
+ public function loadClassCache($name = 'classes', $extension = '.php')
|
|
|
+ {
|
|
|
+ if (!$this->booted) {
|
|
|
+ $this->boot();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($this->classes) {
|
|
|
+ ClassCollectionLoader::load($this->classes, $this->getCacheDir(), $name, $this->debug, true, $extension);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addClassesToCache(array $classes)
|
|
|
+ {
|
|
|
+ $this->classes = array_unique(array_merge($this->classes, $classes));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Gets the request start time (not available if debug is disabled).
|
|
|
*
|
|
@@ -563,8 +591,11 @@ abstract class Kernel implements KernelInterface
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $container->addCompilerPass(new AddClassesToCachePass($this));
|
|
|
$container->compile();
|
|
|
|
|
|
+ $this->addClassesToCache($container->getParameter('kernel.compiled_classes'));
|
|
|
+
|
|
|
return $container;
|
|
|
}
|
|
|
|