Skip to content

Commit

Permalink
[FrameworkBundle] change cache:clear warmup option to no-warmup as mo…
Browse files Browse the repository at this point in the history
…st of the time people will want to use the warmup version (especially in production env)
  • Loading branch information
fabpot committed Mar 21, 2011
1 parent 00d4788 commit 5a528bc
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Expand Up @@ -19,6 +19,7 @@
* Clear and Warmup the cache.
*
* @author Francis Besset <francis.besset@gmail.com>
* @author Fabien Potencier <fabien@symfony.com>
*/
class CacheClearCommand extends CacheWarmupCommand
{
Expand All @@ -30,15 +31,13 @@ protected function configure()
$this
->setName('cache:clear')
->setDefinition(array(
new InputOption('warmup', '', InputOption::VALUE_NONE, 'Warms up the cache')
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache')
))
->setDescription('Clear the cache')
->setHelp(<<<EOF
The <info>cache:clear</info> command clear the cache.
The <info>cache:clear</info> command clears the application cache for the current environment:
<info>./app/console cache:clear --warmup</info>
Warmup option, warms up the cache.
<info>./app/console cache:clear</info>
EOF
)
;
Expand All @@ -60,21 +59,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
$oldCacheDir = $realCacheDir.'_old';

if (!is_writable($realCacheDir)) {
throw new \RuntimeException(sprintf('Unable to write %s directory', $this->realCacheDir));
throw new \RuntimeException(sprintf('Unable to write in "%s" directory', $this->realCacheDir));
}

if (!$input->getOption('warmup')) {
$output->writeln('Clear cache');

if ($input->getOption('no-warmup')) {
rename($realCacheDir, $oldCacheDir);
} else {
parent::execute($input, $output);

$output->writeln('Move cache directories');
rename($realCacheDir, $oldCacheDir);
rename($this->kernelTmp->getCacheDir(), $realCacheDir);

$output->writeln('Clear the old cache');
}

$this->container->get('filesystem')->remove($oldCacheDir);
Expand Down

0 comments on commit 5a528bc

Please sign in to comment.