array( 'short' => 'd', 'description' => 'Reset Parsed and Cached System Data', 'event' => 'adm:OnResetParsedData', ), 'unit-files' => array( 'short' => 'f', 'description' => 'Reset Configs Files Cache and Parsed System Data', 'event' => 'adm:OnResetConfigsCache', ), 'admin-sections' => array( 'short' => 's', 'description' => 'Reset Admin Console Sections', 'event' => 'adm:OnResetSections', ), 'mod-rewrite' => array( 'short' => 'r', 'description' => 'Reset ModRewrite Cache', 'event' => 'adm:OnResetModRwCache', ), 'sms-menu' => array( 'short' => 'm', 'description' => 'Reset SMS Menu Cache', 'event' => 'c:OnResetCMSMenuCache', ), 'templates' => array( 'short' => 't', 'description' => 'Clear Templates Cache', 'event' => 'adm:OnDeleteCompiledTemplates', ), 'all-keys' => array( 'short' => 'k', 'description' => 'Reset All Keys', 'event' => 'adm:OnResetMemcache', ), ); /** * Configures the current command. * * @return void */ protected function configure() { $this ->setName('cache:reset') ->setDescription('Resets the cache'); foreach ( $this->optionMap as $option_name => $option_data ) { $this->addOption( $option_name, $option_data['short'], InputOption::VALUE_NONE, $option_data['description'] ); } } /** * Executes the current command. * * @param InputInterface $input An InputInterface instance. * @param OutputInterface $output An OutputInterface instance. * * @return null|integer */ protected function execute(InputInterface $input, OutputInterface $output) { $success_count = 0; $error_count = 0; foreach ( $this->optionMap as $option_name => $option_data ) { if ( !$input->getOption($option_name) ) { continue; } $success_count++; $output->write('- ' . $option_data['description'] . ' ... '); $event = new \kEvent($option_data['event']); $this->Application->HandleEvent($event); if ( $event->getRedirectParam('action_completed') ) { $output->writeln('OK'); } else { $error_count++; $output->writeln('FAILED'); } } if ( $success_count === 0 ) { throw new \RuntimeException('Please specify at least one reset option'); } return $error_count == 0 ? 0 : 64; } }