[Framework] better fix for the previous commit

This commit is contained in:
Fabien Potencier 2010-08-11 19:35:07 +02:00
parent b64e66dde8
commit fca137fc47
2 changed files with 15 additions and 13 deletions

View File

@ -18,11 +18,20 @@ namespace Symfony\Framework;
*/
class ClassCollectionLoader
{
static protected $loaded;
/**
* @throws \InvalidArgumentException When class can't be loaded
*/
static public function load($classes, $cacheDir, $name, $autoReload)
{
// each $name can only be loaded once per PHP process
if (isset(self::$loaded[$name])) {
return;
}
self::$loaded[$name] = true;
$classes = array_unique($classes);
$cache = $cacheDir.'/'.$name.'.php';

View File

@ -36,8 +36,6 @@ use Symfony\Framework\ClassCollectionLoader;
*/
abstract class Kernel implements HttpKernelInterface, \Serializable
{
static protected $loaded;
protected $bundles;
protected $bundleDirs;
protected $container;
@ -127,17 +125,12 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
$this->container = $this->initializeContainer();
// load core classes
// can only be loaded once (for all Kernel in the same process)
if (!self::$loaded) {
self::$loaded = true;
ClassCollectionLoader::load(
$this->container->getParameter('kernel.compiled_classes'),
$this->container->getParameter('kernel.cache_dir'),
'classes',
$this->container->getParameter('kernel.debug')
);
}
ClassCollectionLoader::load(
$this->container->getParameter('kernel.compiled_classes'),
$this->container->getParameter('kernel.cache_dir'),
'classes',
$this->container->getParameter('kernel.debug')
);
foreach ($this->bundles as $bundle) {
$bundle->setContainer($this->container);