/** * execute command * * @param InputInterface $input * @param OutputInterface $output */ public function execute(InputInterface $input, OutputInterface $output) { $subfolder = $input->getOption('subfolder'); if ($subfolder == null) { $output->writeln('<error>Sorry, you did not enter cache sub folder name.</error>'); unset($subfolder); return false; } if ($subfolder != null) { $Cache = new \System\Libraries\Cache(); $cache_config = $Cache->getCacheConfig(); $style = new \Symfony\Component\Console\Formatter\OutputFormatterStyle('white', 'green'); $output->getFormatter()->setStyle('success', $style); unset($style); if ($subfolder == '*') { // entered command to delete all cache. $Cache->deleteAllFile(); $output->writeln('<success>All cache was deleted successfully.</success>'); } else { if (is_array($cache_config) && array_key_exists('driver', $cache_config) && $cache_config['driver'] == 'Filesystem' && array_key_exists('cache_path', $cache_config)) { $adapter = new \League\Flysystem\Adapter\Local($cache_config['cache_path']); $Filesystem = new \League\Flysystem\Filesystem($adapter); $Filesystem->addPlugin(new \League\Flysystem\Plugin\ListPaths()); try { $Filesystem->getMetadata($subfolder); // selected sub folder exists. $Cache->setSubFolder($subfolder); $Cache->deleteAllFile(); unset($Filesystem); $output->writeln('<success>The cache inside "' . $subfolder . '" folder was deleted successfully.</success>'); } catch (\Exception $e) { $output->writeln('<error>The "' . $subfolder . '" cache folder is not found.</error>'); } unset($adapter, $Filesystem); } } unset($Cache, $cache_config); } unset($subfolder); }