8000 [HttpKernel] enabled cache-reloading when cache file is rebuilt by stampycode · Pull Request #20033 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] enabled cache-reloading when cache file is rebuilt #20033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpKernel] enabled cache-reloading when cache file is rebuilt
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
commit d3b393cfed0b98fcf727f7d1ef401a2c0b9110d4
8 changes: 7 additions & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,21 @@ protected function initializeContainer()
$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
$fresh = true;
for ($classVersion = 0; class_exists($class . ($classVersion ?: '')); $classVersion++);
if (!$cache->isFresh()) {
$container = $this->buildContainer();
$container->compile();
$class .= $classVersion ?: '';
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());

$fresh = false;
} else {
$class .= $classVersion ? $classVersion - 1 : '';
}

require_once $cache->getPath();
if(!in_array($class, get_declared_classes())) {
require $cache->getPath();
}

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