feature #15978 Updated the styles of the cache commands (javiereguiluz)
This PR was merged into the 2.8 branch. Discussion ---------- Updated the styles of the cache commands | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR uses comment() which hasn't been merged yet. WIP PR at #15964 ![cache_1](https://cloud.githubusercontent.com/assets/73419/10141826/f41d5952-660e-11e5-8435-b78aef4130bb.png) ![cache_2](https://cloud.githubusercontent.com/assets/73419/10141828/f6da7e40-660e-11e5-80a9-3546e912bc0f.png) ![cache_3](https://cloud.githubusercontent.com/assets/73419/10141831/f9dea92c-660e-11e5-9c1f-3be42a263696.png) Commits -------44c5416
Updated the styles for the "cache:warmup" command08b2959
Updated the style for the "cache:clear" command
This commit is contained in:
commit
7bc3ec0403
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
@ -53,6 +54,9 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$outputIsVerbose = $output->isVerbose();
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
|
||||
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||
$oldCacheDir = $realCacheDir.'_old';
|
||||
$filesystem = $this->getContainer()->get('filesystem');
|
||||
@ -66,7 +70,7 @@ EOF
|
||||
}
|
||||
|
||||
$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->comment(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')) {
|
||||
@ -78,14 +82,14 @@ EOF
|
||||
$warmupDir = substr($realCacheDir, 0, -1).'_';
|
||||
|
||||
if ($filesystem->exists($warmupDir)) {
|
||||
if ($output->isVerbose()) {
|
||||
$output->writeln(' Clearing outdated warmup directory');
|
||||
if ($outputIsVerbose) {
|
||||
$output->comment('Clearing outdated warmup directory...');
|
||||
}
|
||||
$filesystem->remove($warmupDir);
|
||||
}
|
||||
|
||||
if ($output->isVerbose()) {
|
||||
$output->writeln(' Warming up cache');
|
||||
if ($outputIsVerbose) {
|
||||
$output->comment('Warming up cache...');
|
||||
}
|
||||
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
|
||||
|
||||
@ -96,15 +100,17 @@ EOF
|
||||
$filesystem->rename($warmupDir, $realCacheDir);
|
||||
}
|
||||
|
||||
if ($output->isVerbose()) {
|
||||
$output->writeln(' Removing old cache directory');
|
||||
if ($outputIsVerbose) {
|
||||
$output->comment('Removing old cache directory...');
|
||||
}
|
||||
|
||||
$filesystem->remove($oldCacheDir);
|
||||
|
||||
if ($output->isVerbose()) {
|
||||
$output->writeln(' Done');
|
||||
if ($outputIsVerbose) {
|
||||
$output->comment('Finished');
|
||||
}
|
||||
|
||||
$output->success(sprintf('Cache for the "%s" environment (debug=%s) was succesfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
/**
|
||||
* Warmup the cache.
|
||||
@ -53,8 +54,10 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output = new SymfonyStyle($input, $output);
|
||||
|
||||
$kernel = $this->getContainer()->get('kernel');
|
||||
$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)));
|
||||
$output->comment(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');
|
||||
|
||||
@ -63,5 +66,7 @@ EOF
|
||||
}
|
||||
|
||||
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
|
||||
|
||||
$output->success(sprintf('Cache for the "%s" environment (debug=%s) was succesfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user