コード例 #1
0
 public function testStoreBackupConfig()
 {
     $path = '/tmp/test-path';
     $data = ['yaml' => 'data'];
     $yamlString = 'YamlString';
     $filepath = $path . DIRECTORY_SEPARATOR . FilesystemRepositoryInterface::DIR_CONFIG . DIRECTORY_SEPARATOR . FilesystemRepositoryInterface::FILENAME_CONFIG_BACKUP . FilesystemRepositoryInterface::FILE_EXTENSION_CONFIG;
     $this->yamlDumper->expects($this->once())->method('dump')->with($data, 5)->willReturn($yamlString);
     $this->filesystem->expects($this->once())->method('dumpFile')->with($filepath, $yamlString);
     $this->filesystemRepository->storeBackupConfig($path, $data);
 }
コード例 #2
0
 /**
  * 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);
 }