Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1f6411

Browse filesBrowse files
jrmyiofabpot
authored andcommitted
[FrameworkBundle] added feedback in cache:clear
1 parent 0af3ca3 commit a1f6411
Copy full SHA for a1f6411

File tree

Expand file treeCollapse file tree

1 file changed

+36
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+36
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
+36-1Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6666
}
6767

6868
$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)));
69+
$output->writeln($this->getClearingCacheMessage($output, $kernel));
70+
7071
$this->getContainer()->get('cache_clearer')->clear($realCacheDir);
7172

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

7980
if ($filesystem->exists($warmupDir)) {
81+
$this->writelnIfVerbose($output, 'Clearing outdated warmup directory...');
8082
$filesystem->remove($warmupDir);
8183
}
8284

85+
$this->writelnIfVerbose($output, 'Warming up cache...');
8386
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
8487

8588
$filesystem->rename($realCacheDir, $oldCacheDir);
8689
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
8790
sleep(1); // workaround for Windows PHP rename bug
8891
}
8992
$filesystem->rename($warmupDir, $realCacheDir);
93+
$this->writelnIfVerbose($output, 'Warm up completed...');
9094
}
9195

96+
$this->writelnIfVerbose($output, 'Removing old cache directory...');
9297
$filesystem->remove($oldCacheDir);
98+
$this->writelnIfVerbose($output, 'Completed clearing cache' . ($input->getOption('no-warmup') ? "!" : " and warmup!"));
99+
}
100+
101+
/**
102+
* @param OutputInterface $output
103+
* @param KernelInterface $kernel
104+
* @return string
105+
*/
106+
protected function getClearingCacheMessage(OutputInterface $output, KernelInterface $kernel){
107+
$message = 'Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>';
108+
$message .= $this->isVerbose($output) ? ":" : "";
109+
return sprintf($message, $kernel->getEnvironment(), var_export($kernel->isDebug(), true));
110+
}
111+
112+
/**
113+
* @param OutputInterface $output
114+
* @param string $message
115+
*/
116+
protected function writelnIfVerbose(OutputInterface $output, $message){
117+
if ($this->isVerbose($output)){
118+
$output->writeln($message);
119+
}
120+
}
121+
122+
/**
123+
* @param OutputInterface $output
124+
* @return bool
125+
*/
126+
protected function isVerbose(OutputInterface $output){
127+
return OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity();
93128
}
94129

95130
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.