[FrameworkBundle] Generate the class cache when warming up the cache
This commit is contained in:
parent
6266b72ddc
commit
f09789b192
@ -31,3 +31,5 @@ CHANGELOG
|
||||
`gc_probability`/`gc_divisor` chance of being run. The `gc_maxlifetime` defines
|
||||
how long a session can idle for. It is different from cookie lifetime which
|
||||
declares how long a cookie can be stored on the remote client.
|
||||
* Commands cache:warmup and cache:clear (unless --no-warmup is specified) now
|
||||
create the class cache.
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@ -63,7 +64,8 @@ EOF
|
||||
}
|
||||
|
||||
$kernel = $this->getContainer()->get('kernel');
|
||||
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
$debug = $kernel->isDebug();
|
||||
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($debug, true)));
|
||||
|
||||
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
|
||||
|
||||
@ -76,11 +78,21 @@ EOF
|
||||
|
||||
rename($realCacheDir, $oldCacheDir);
|
||||
rename($warmupDir, $realCacheDir);
|
||||
|
||||
$this->createClassCache($realCacheDir, $debug);
|
||||
}
|
||||
|
||||
$this->getContainer()->get('filesystem')->remove($oldCacheDir);
|
||||
}
|
||||
|
||||
protected function createClassCache($cacheDir, $debug)
|
||||
{
|
||||
$classmap = $cacheDir.'/classes.map';
|
||||
if (is_file($classmap)) {
|
||||
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', $debug, false, '.php');
|
||||
}
|
||||
}
|
||||
|
||||
protected function warmup($warmupDir, $enableOptionalWarmers = true)
|
||||
{
|
||||
$this->getContainer()->get('filesystem')->remove($warmupDir);
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@ -56,6 +57,12 @@ EOF
|
||||
$warmer->enableOptionalWarmers();
|
||||
}
|
||||
|
||||
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
|
||||
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||
$warmer->warmUp($cacheDir);
|
||||
|
||||
$classmap = $cacheDir.'/classes.map';
|
||||
if (is_file($classmap)) {
|
||||
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', $kernel->isDebug(), false, '.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user