settings = $settings; $this->logger = $logger; $this->translator = $translator; parent::__construct(); } protected function configure() { $this->setName('cache:clear') ->setDescription('Clear cache') ->setHelp('Clears either all caches or those specified with option --cache. Think twice before you clear a cache with previews. Depending on the number of documents in your DMS, it may take a long time to recreate the cache.') ->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from this cache.', null) ->addOption('force', '', InputOption::VALUE_NONE, 'Force operation, do not ask') ; } protected function execute(InputInterface $input, OutputInterface $output) : int { $app = $this->getApplication(); $settings = $this->settings; $logger = $this->logger; $translator = $this->translator; $output->writeln("Using configuration from '".$settings->_configFilePath."'."); if (!is_writable($settings->_cacheDir)) { $output->writeln(sprintf("The cache dir '%s' is not writable for the system user running this script.", $settings->_cacheDir)); return Command::FAILURE; } if (!$input->getOption('force')) { $helper = new QuestionHelper(); $question = new ConfirmationQuestion('Do you really want to clear the cache? ', false); if (!$helper->ask($input, $output, $question)) { return Command::SUCCESS; } } require_once('inc/inc.DBInit.php'); $post = array_flip($input->getOption('cache')); array_walk($post, function (&$v, $k) {$v=1;}); $controller = Controller::factory('ClearCache', array('settings'=>$settings)); $controller->setParam('post', $post); if(!$ret = $controller->run()) { } return Command::SUCCESS; } } // vim: ts=4 sw=4 expandtab