Skip to content

Commit 08b2959

Browse files
committed
Updated the style for the "cache:clear" command
1 parent 3c19ae0 commit 08b2959

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Input\InputOption;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\Console\Style\SymfonyStyle;
1718
use Symfony\Component\HttpKernel\KernelInterface;
1819
use Symfony\Component\Finder\Finder;
1920

@@ -53,6 +54,9 @@ protected function configure()
5354
*/
5455
protected function execute(InputInterface $input, OutputInterface $output)
5556
{
57+
$outputIsVerbose = $output->isVerbose();
58+
$output = new SymfonyStyle($input, $output);
59+
5660
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
5761
$oldCacheDir = $realCacheDir.'_old';
5862
$filesystem = $this->getContainer()->get('filesystem');
@@ -66,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6670
}
6771

6872
$kernel = $this->getContainer()->get('kernel');
69-
$output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
73+
$output->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
7074
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
7175

7276
if ($input->getOption('no-warmup')) {
@@ -78,14 +82,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
7882
$warmupDir = substr($realCacheDir, 0, -1).'_';
7983

8084
if ($filesystem->exists($warmupDir)) {
81-
if ($output->isVerbose()) {
82-
$output->writeln(' Clearing outdated warmup directory');
85+
if ($outputIsVerbose) {
86+
$output->comment('Clearing outdated warmup directory...');
8387
}
8488
$filesystem->remove($warmupDir);
8589
}
8690

87-
if ($output->isVerbose()) {
88-
$output->writeln(' Warming up cache');
91+
if ($outputIsVerbose) {
92+
$output->comment('Warming up cache...');
8993
}
9094
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
9195

@@ -96,15 +100,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
96100
$filesystem->rename($warmupDir, $realCacheDir);
97101
}
98102

99-
if ($output->isVerbose()) {
100-
$output->writeln(' Removing old cache directory');
103+
if ($outputIsVerbose) {
104+
$output->comment('Removing old cache directory...');
101105
}
102106

103107
$filesystem->remove($oldCacheDir);
104108

105-
if ($output->isVerbose()) {
106-
$output->writeln(' Done');
109+
if ($outputIsVerbose) {
110+
$output->comment('Finished');
107111
}
112+
113+
$output->success(sprintf('Cache for the "%s" environment (debug=%s) was succesfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
108114
}
109115

110116
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy