/**
  * Factory for creating object from array
  *
  * @param array $action
  * @return MappingAction
  * @author Daniel Wendlandt
  */
 public static function createFromArray(array $action)
 {
     $mappingAction = new MappingAction();
     $mappingAction->setStrategy($action['strategy']);
     $mappingAction->setSourceIndex($action['source_index']);
     $mappingAction->setSourceType($action['source_type']);
     $mappingAction->setTargetIndex($action['target_index']);
     $mappingAction->setTargetType($action['target_type']);
     return $mappingAction;
 }
 /**
  * Forces User to select index/type from existing ones
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param RestoreStrategy\MappingAction $mappingAction
  * @return RestoreStrategy\MappingAction
  * @author Daniel Wendlandt
  */
 private function askForExistingIndexType(InputInterface $input, OutputInterface $output, RestoreStrategy\MappingAction $mappingAction)
 {
     $existingQuestions = array();
     /** @var Index $index */
     foreach ($this->targetMappings->getIndices() as $index) {
         /** @var Type $type */
         foreach ($index->getTypes() as $type) {
             $existingQuestions[] = $index->getName() . '/' . $type->getName();
         }
     }
     $questionExisting = new ChoiceQuestion('Please select one of this existing indices/types', $existingQuestions);
     $helper = $this->getHelper('question');
     $answerExisting = $helper->ask($input, $output, $questionExisting);
     $exploded = explode('/', $answerExisting);
     $mappingAction->setTargetIndex($exploded[0]);
     $mappingAction->setTargetType($exploded[1]);
     $this->askForMappingStrategy($input, $output, $mappingAction);
     return $mappingAction;
 }
 /**
  * Process all given indices/types for only one main strategy
  *
  * @param string $strategy
  * @param Mappings $mappings
  * @author Daniel Wendlandt
  */
 public function processMappingsForStrategy($strategy, Mappings $mappings)
 {
     $this->mappings = array();
     /** @var Index $index */
     foreach ($mappings->getIndices() as $index) {
         /** @var Type $type */
         foreach ($index->getTypes() as $type) {
             $mappingAction = new MappingAction();
             $mappingAction->setStrategy($strategy);
             $mappingAction->setSourceIndex($index->getName());
             $mappingAction->setSourceType($type->getName());
             $mappingAction->setTargetIndex($index->getName());
             $mappingAction->setTargetType($type->getName());
             $this->addMappingAction($mappingAction);
         }
     }
 }