Skip to content

Commit

Permalink
Enable cache-reloading when cache file is rebuilt.
Browse files Browse the repository at this point in the history
This allows the cache file to be deleted and thus rebuilt between Container builds in WebTestCase scenario, to enable testing of multiple configurations of the same application through WebTestCase.
  • Loading branch information
stampy committed Sep 23, 2016
1 parent fd0d288 commit ba2a01e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,16 +478,23 @@ protected function initializeContainer()
{
$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
static $classn = '';
$fresh = true;
if (!$cache->isFresh()) {
$container = $this->buildContainer();
$container->compile();
$classn = (is_numeric($classn) ? $classn+1 : 1);
$class .= $classn;
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());

$fresh = false;
} else {
$class .= $classn;
}

require_once $cache->getPath();
if(!class_exists($class)) {
require $cache->getPath();
}

$this->container = new $class();
$this->container->set('kernel', $this);
Expand Down

0 comments on commit ba2a01e

Please sign in to comment.