Skip to content

Commit

Permalink
[HttpKernel] removed the need to keep the compiled classes in the con…
Browse files Browse the repository at this point in the history
…tainer
  • Loading branch information
fabpot committed Jul 22, 2011
1 parent e16c226 commit eb7c86b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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.
Expand All @@ -22,6 +23,13 @@
*/
class AddClassesToCachePass implements CompilerPassInterface
{
private $kernel;

public function __construct(Kernel $kernel)
{
$this->kernel = $kernel;
}

/**
* {@inheritDoc}
*/
Expand All @@ -34,6 +42,6 @@ public function process(ContainerBuilder $container)
}
}

$container->setParameter('kernel.compiled_classes', array_unique($classes));
$this->kernel->setClassCache($container->getParameterBag()->resolveValue(array_unique($classes)));

This comment has been minimized.

Copy link
@stof

stof Jul 22, 2011

Member

array_unique should be applied on the resolved array: what if 2 parameters have the same value ?

}
}
11 changes: 8 additions & 3 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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;
Expand Down Expand Up @@ -402,6 +401,14 @@ public function loadClassCache($name = 'classes', $extension = '.php')
}
}

/**
* 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).
*
Expand Down Expand Up @@ -641,8 +648,6 @@ protected function buildContainer()
$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;
}

Expand Down

0 comments on commit eb7c86b

Please sign in to comment.