[FrameworkBundle] Allow cache:clear/warmup to skip optional warmers
This commit is contained in:
parent
11f83a6481
commit
42c98921a2
|
@ -36,6 +36,7 @@ class CacheClearCommand extends ContainerAwareCommand
|
|||
->setName('cache:clear')
|
||||
->setDefinition(array(
|
||||
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
|
||||
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
||||
))
|
||||
->setDescription('Clears the cache')
|
||||
->setHelp(<<<EOF
|
||||
|
@ -71,7 +72,7 @@ EOF
|
|||
} else {
|
||||
$warmupDir = $realCacheDir.'_new';
|
||||
|
||||
$this->warmup($warmupDir);
|
||||
$this->warmup($warmupDir, !$input->getOption('no-optional-warmers'));
|
||||
|
||||
rename($realCacheDir, $oldCacheDir);
|
||||
rename($warmupDir, $realCacheDir);
|
||||
|
@ -80,7 +81,7 @@ EOF
|
|||
$this->getContainer()->get('filesystem')->remove($oldCacheDir);
|
||||
}
|
||||
|
||||
protected function warmup($warmupDir)
|
||||
protected function warmup($warmupDir, $enableOptionalWarmers = true)
|
||||
{
|
||||
$this->getContainer()->get('filesystem')->remove($warmupDir);
|
||||
|
||||
|
@ -96,7 +97,11 @@ EOF
|
|||
$kernel->boot();
|
||||
|
||||
$warmer = $kernel->getContainer()->get('cache_warmer');
|
||||
$warmer->enableOptionalWarmers();
|
||||
|
||||
if ($enableOptionalWarmers) {
|
||||
$warmer->enableOptionalWarmers();
|
||||
}
|
||||
|
||||
$warmer->warmUp($warmupDir);
|
||||
|
||||
// fix container files and classes
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +29,9 @@ class CacheWarmupCommand extends ContainerAwareCommand
|
|||
{
|
||||
$this
|
||||
->setName('cache:warmup')
|
||||
->setDefinition(array(
|
||||
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
|
||||
))
|
||||
->setDescription('Warms up an empty cache')
|
||||
->setHelp(<<<EOF
|
||||
The <info>cache:warmup</info> command warms up the cache.
|
||||
|
@ -47,7 +51,11 @@ EOF
|
|||
$output->writeln(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
|
||||
$warmer = $this->getContainer()->get('cache_warmer');
|
||||
$warmer->enableOptionalWarmers();
|
||||
|
||||
if (!$input->getOption('no-optional-warmers')) {
|
||||
$warmer->enableOptionalWarmers();
|
||||
}
|
||||
|
||||
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue