Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[FrameworkBundle] added --without-debug option to cache:clear as the …

…debug flag value can be different from the one used for the command execution (think generating the prod cache but still with debug information when running the command)
  • Loading branch information...
commit 85778caba16ad6830fdc28eaa6ee8c1e91d009ef 1 parent e4a636a
Fabien Potencier fabpot authored
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
23 src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
View
@@ -33,13 +33,16 @@ protected function configure()
$this
->setName('cache:clear')
->setDefinition(array(
- new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache')
+ new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
+ new InputOption('without-debug', '', InputOption::VALUE_NONE, 'If the cache is warmed up, whether to disable debugging or not'),
))
->setDescription('Clear the cache')
->setHelp(<<<EOF
-The <info>cache:clear</info> command clears the application cache for the current environment:
+The <info>cache:clear</info> command clears the application cache for a given environment
+and debug mode:
-<info>./app/console cache:clear</info>
+<info>./app/console cache:clear dev</info>
+<info>./app/console cache:clear prod --without-debug</info>
EOF
)
;
@@ -54,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$oldCacheDir = $realCacheDir.'_old';
if (!is_writable($realCacheDir)) {
- throw new \RuntimeException(sprintf('Unable to write in "%s" directory', $this->realCacheDir));
+ throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $this->realCacheDir));
}
if ($input->getOption('no-warmup')) {
@@ -62,7 +65,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$warmupDir = $realCacheDir.'_new';
- $this->warmup($warmupDir);
+ $this->warmup(!$input->getOption('without-debug'), $warmupDir);
rename($realCacheDir, $oldCacheDir);
rename($warmupDir, $realCacheDir);
@@ -71,18 +74,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->container->get('filesystem')->remove($oldCacheDir);
}
- protected function warmup($warmupDir)
+ protected function warmup($debug, $warmupDir)
{
$this->container->get('filesystem')->remove($warmupDir);
- $kernel = $this->getTempKernel($this->container->get('kernel'), $warmupDir);
+ $kernel = $this->getTempKernel($this->container->get('kernel'), $debug, $warmupDir);
$kernel->boot();
$warmer = $kernel->getContainer()->get('cache_warmer');
$warmer->enableOptionalWarmers();
$warmer->warmUp($warmupDir);
- // rename container files
+ // fix container files and classes
$finder = new Finder();
foreach ($finder->files()->name(get_class($kernel->getContainer()).'*')->in($warmupDir) as $file) {
$content = file_get_contents($file);
@@ -92,7 +95,7 @@ protected function warmup($warmupDir)
}
}
- protected function getTempKernel(KernelInterface $parent, $warmupDir)
+ protected function getTempKernel(KernelInterface $parent, $debug, $warmupDir)
{
$parentClass = get_class($parent);
$rand = uniqid();
@@ -124,6 +127,6 @@ protected function getContainerClass()
require_once $file;
@unlink($file);
- return new $class($parent->getEnvironment(), $parent->isDebug());
+ return new $class($parent->getEnvironment(), $debug);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.