/** * Aksing for strategy * * @param InputInterface $input * @param OutputInterface $output * @param RestoreJob $job * @return RestoreStrategy * @author Daniel Wendlandt */ private function askForRestoreStrategy(InputInterface $input, OutputInterface $output, RestoreJob $job) { $strategies = array(RestoreStrategy::STRATEGY_RESET, RestoreStrategy::STRATEGY_ADD, RestoreStrategy::STRATEGY_CUSTOM); $questions = array('Delete all indices/types if exist and insert data', 'Do not touch indices/types if exist and add data', 'Define custom mappings and insert the data'); $helper = $this->getHelper('question'); $question = new ChoiceQuestion('<info>Please decide the strategy for restoring teh data ?</info>', $questions); $mappingStrategyAnswer = $helper->ask($input, $output, $question); $strategy = new RestoreStrategy(); foreach ($questions as $strategyKey => $strategyQuestion) { if ($mappingStrategyAnswer === $strategyQuestion) { $strategy->setStrategy($strategies[$strategyKey]); } } if (RestoreStrategy::STRATEGY_CUSTOM !== $strategy->getStrategy()) { $strategy->processMappingsForStrategy($strategy->getStrategy(), $job->getMappings()); return $strategy; } $this->askForCustomMapping($input, $output, $job, $strategy); return $strategy; }