. */ /* */ /*************************************************************************************/ namespace Thelia\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOException; use Thelia\Command\ContainerAwareCommand; class CacheClear extends ContainerAwareCommand { protected function configure() { $this ->setName("cache:clear") ->setDescription("Invalidate all caches"); } protected function execute(InputInterface $input, OutputInterface $output) { $cacheDir = $this->getContainer()->getParameter("kernel.cache_dir"); if (!is_writable($cacheDir)) { throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $cacheDir)); } $output->writeln(sprintf("Clearing cache in %s directory", $cacheDir)); $fs = new Filesystem(); try { $fs->remove($cacheDir); $output->writeln("cache cleared successfully"); } catch(IOException $e) { $output->writeln(sprintf("error during clearing cache : %s", $e->getMessage())); } } }