/** * Asking for indeces/types wich should be used * * @param InputInterface $input * @param OutputInterface $output * @param BackupJob $job * @return mixed * @author Daniel Wendlandt */ private function askForIndicesTypes(InputInterface $input, OutputInterface $output, BackupJob $job) { $mappings = array(); $mappings[] = 'all'; /** @var Index $index */ foreach ($job->getMappings()->getIndices() as $index) { /** @var Type $type */ foreach ($index->getTypes() as $type) { $mappings[] = $index->getName() . '/' . $type->getName(); } } $helper = $this->getHelper('question'); $question = new ChoiceQuestion('<info>Please select indices/types that should be dumped (separate multiple by colon)</info> [<comment>all</comment>]:', $mappings, '0'); $question->setMultiselect(true); return $helper->ask($input, $output, $question); }
/** * Stores config to yml config * * @param BackupJob $job * @param OutputInterface $output * @author Daniel Wendlandt */ private function storeBackupConfig(BackupJob $job, OutputInterface $output) { $indices = array(); /** @var Index $index */ foreach ($job->getMappings()->getIndices() as $index) { /** @var Type $type */ foreach ($index->getTypes() as $type) { $indices[] = array('index' => $index->getName(), 'type' => $type->getName()); } } $config = array('name' => $job->getName(), 'target' => $job->getTarget(), 'host' => $job->getHost(), 'port' => $job->getPort(), 'indices' => $indices, 'created_at' => $job->getCreatedAt()->format('Y-m-d H:i:s')); $this->filesystem->storeBackupConfig($job->getPath(), $config); $output->writeln('<info>*** Stored backup-config to file im yaml format ***</info>' . PHP_EOL); }