8000 Feedback in cache:clear by jrmyio · Pull Request #9463 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Feedback in cache:clear #9463

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

Closed
wants to merge 7 commits into from
Closed
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
Next Next commit
Show additional messages only in verbose
  • Loading branch information
jrmyio committed Nov 8, 2013
commit 5a0da3800bedc9d47699acf63d72d71e119d1b61
42 changes: 36 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$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)));
$output->writeln($this->getClearingCacheMessage($output, $kernel));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you move it to a method?


$this->getContainer()->get('cache_clearer')->clear($realCacheDir);

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

if ($filesystem->exists($warmupDir)) {
$output->writeln('Clearing outdated warmup directory...');
$this->writelnIfVerbose($output, 'Clearing outdated warmup directory...');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a space after directory

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope

$filesystem->remove($warmupDir);
}

$output->writeln('Warming up cache...');
$this->writelnIfVerbose($output, '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);
$output->writeln('Warm up completed...');
$this->writelnIfVerbose($output, 'Warm up completed...');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to remove the 3 dots.

}

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

/**
* @param OutputInterface $output
* @param KernelInterface $kernel
* @return string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a new line before @return

*/
protected function getClearingCacheMessage(OutputInterface $output, KernelInterface $kernel){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cs = space between ) and {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And { on new line, the ) { is only used for conditions and not for blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

$message = 'Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to define a seperate $message variable.

$message .= $this->isVerbose($output) ? ":" : "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a space before the return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include this in the sprintf

return sprintf($message, $kernel->getEnvironment(), var_export($kernel->isDebug(), true));
}

/**
* @param OutputInterface $output
* @param string $message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure $message lines up with $output

*/
protected function writelnIfVerbose(OutputInterface $output, $message){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run phpcs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between ) and {

if ($this->isVerbose($output)){
$output->writeln($message);
}
}

/**
* @param OutputInterface $output
* @return bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line here too

*/
protected function isVerbose(OutputInterface $output){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

return OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity();
}

/**
Expand Down
0