8000 added feedback to the cache:clear command by fabpot · Pull Request #9966 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

added feedback to the cache:clear command #9966

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

Merged
merged 2 commits into from
Jan 7, 2014
Merged
Changes from 1 commit
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
Prev Previous commit
[FrameworkBundle] simplified code
  • Loading branch information
fabpot committed Jan 7, 2014
commit f2261da45037077ced47de2556a499115fead135
47 changes: 13 additions & 34 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
880D
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$kernel = $this->getContainer()->get('kernel');
$output->writeln($this->getClearingCacheMessage($output, $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)));
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);

if ($input->getOption('no-warmup')) {
Expand All @@ -78,55 +77,35 @@ protected function execute(InputInterface $input, OutputInterface $output)
$warmupDir = substr($realCacheDir, 0, -1).'_';

if ($filesystem->exists($warmupDir)) {
$this->writelnIfVerbose($output, 'Clearing outdated warmup directory...');
if ($output->isVerbose()) {
$output->writeln(' Clearing outdated warmup directory');
}
$filesystem->remove($warmupDir);
}

$this->writelnIfVerbose($output, 'Warming up cache...');
if ($output->isVerbose()) {
$output->writeln(' Warming up cache');
}
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));

$filesystem->rename($realCacheDir, $oldCacheDir);
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
sleep(1); // workaround for Windows PHP rename bug
}
$filesystem->rename($warmupDir, $realCacheDir);
$this->writelnIfVerbose($output, 'Warm up completed...');
}

$this->writelnIfVerbose($output, 'Removing old cache directory...');
$filesystem->remove($oldCacheDir);
$this->writelnIfVerbose($output, 'Completed clearing cache' . ($input->getOption('no-warmup') ? "!" : " and warmup!"));
}
if ($output->isVerbose()) {
$output->writeln(' Removing old cache directory');
}

/**
* @param OutputInterface $output
* @param KernelInterface $kernel
* @return string
*/
protected function getClearingCacheMessage(OutputInterface $output, KernelInterface $kernel){
$message = 'Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>';
$message .= $this->isVerbose($output) ? ":" : "";
return sprintf($message, $kernel->getEnvironment(), var_export($kernel->isDebug(), true));
}
$filesystem->remove($oldCacheDir);

/**
* @param OutputInterface $output
* @param string $message
*/
protected function writelnIfVerbose(OutputInterface $output, $message){
if ($this->isVerbose($output)){
$output->writeln($message);
if ($output->isVerbose()) {
$output->writeln(' Done');
}
}

/**
* @param OutputInterface $output
* @return bool
*/
protected function isVerbose(OutputInterface $output){
return OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity();
}

/**
* @param string $warmupDir
* @param string $realCacheDir
Expand Down
0