/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $realCacheDir = $this->getConfig()->getCacheDir(); $oldCacheDir = $realCacheDir . '_old'; $filesystem = new Filesystem(); if (!is_writable($realCacheDir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir)); } if ($filesystem->exists($oldCacheDir)) { $filesystem->remove($oldCacheDir); } $output->writeln(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $this->getConfig()->getEnv(), var_export($this->getConfig()->isDebug(), true))); $filesystem->clear($realCacheDir); }