settings = $settings;
$this->logger = $logger;
$this->translator = $translator;
parent::__construct();
}
protected function configure()
{
$this->setName('cache:clear')
->setDescription('Clears the cache')
->setHelp('Clears all cache or those specified.')
->addOption('cache', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove files from cache.', null)
;
}
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;
}
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