From a1f64114ab9822473694d2ff62f4cc9dffe37435 Mon Sep 17 00:00:00 2001 From: ConneXNL Date: Tue, 7 Jan 2014 15:01:26 +0100 Subject: [PATCH 1/2] [FrameworkBundle] added feedback in cache:clear --- .../Command/CacheClearCommand.php | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index b7e4bfd0c6336..faf58103e8a74 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -66,7 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } $kernel = $this->getContainer()->get('kernel'); - $output->writeln(sprintf('Clearing the cache for the %s environment with debug %s', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); + $output->writeln($this->getClearingCacheMessage($output, $kernel)); + $this->getContainer()->get('cache_clearer')->clear($realCacheDir); if ($input->getOption('no-warmup')) { @@ -77,9 +78,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $warmupDir = substr($realCacheDir, 0, -1).'_'; if ($filesystem->exists($warmupDir)) { + $this->writelnIfVerbose($output, 'Clearing outdated warmup directory...'); $filesystem->remove($warmupDir); } + $this->writelnIfVerbose($output, 'Warming up cache...'); $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers')); $filesystem->rename($realCacheDir, $oldCacheDir); @@ -87,9 +90,41 @@ protected function execute(InputInterface $input, OutputInterface $output) 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!")); + } + + /** + * @param OutputInterface $output + * @param KernelInterface $kernel + * @return string + */ + protected function getClearingCacheMessage(OutputInterface $output, KernelInterface $kernel){ + $message = 'Clearing the cache for the %s environment with debug %s'; + $message .= $this->isVerbose($output) ? ":" : ""; + return sprintf($message, $kernel->getEnvironment(), var_export($kernel->isDebug(), true)); + } + + /** + * @param OutputInterface $output + * @param string $message + */ + protected function writelnIfVerbose(OutputInterface $output, $message){ + if ($this->isVerbose($output)){ + $output->writeln($message); + } + } + + /** + * @param OutputInterface $output + * @return bool + */ + protected function isVerbose(OutputInterface $output){ + return OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity(); } /** From f2261da45037077ced47de2556a499115fead135 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 7 Jan 2014 15:06:02 +0100 Subject: [PATCH 2/2] [FrameworkBundle] simplified code --- .../Command/CacheClearCommand.php | 47 +++++-------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php index faf58103e8a74..28dac98e35916 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php @@ -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 %s environment with debug %s', $kernel->getEnvironment(), var_export($kernel->isDebug(), true))); $this->getContainer()->get('cache_clearer')->clear($realCacheDir); if ($input->getOption('no-warmup')) { @@ -78,11 +77,15 @@ 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); @@ -90,43 +93,19 @@ protected function execute(InputInterface $input, OutputInterface $output) 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 %s environment with debug %s'; - $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 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