/** * {@inheritdoc} */ public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter) { $this->output->writeln(' * <comment>import "export.xml" to "' . $parameter['path'] . '"</comment>'); $tempfile = $this->temporaryFileSystem->createTemporaryFile('jackrabbit'); $handle = fopen($tempfile, 'w+'); file_put_contents($tempfile, $source->read('export.xml')); fclose($handle); $this->import($this->getSession($parameter), $parameter['path'], $tempfile); }
/** * {@inheritdoc} */ public function restore(Filesystem $source, Filesystem $destination, ReadonlyDatabase $database, array $parameter) { $tempFile = $this->temporaryFileSystem->createTemporaryFile('mysql'); file_put_contents($tempFile, $source->read('dump.sql')); $process = new Process($this->getImportCommand($parameter['username'], $parameter['password'], $parameter['database'], $tempFile)); $process->run(); while ($process->isRunning()) { // waiting for process to finish } $this->output->writeln(sprintf(' * <comment>%s</comment>', $this->getImportCommand($parameter['username'], $parameter['password'], $parameter['database'], 'dump.sql', true))); }
/** * {@inheritdoc} */ public function open($name) { $tempFileName = $this->temporaryFileSystem->createTemporaryFile(); $stream = $this->localFilesystem->readStream(sprintf('%s/%s.zip', $this->name, $name)); file_put_contents($tempFileName, $stream); $filesystem = new Filesystem(new ReadonlyAdapter(new ZipArchiveAdapter($tempFileName))); $filesystem->addPlugin(new ListFiles()); return $filesystem; }
public function testOpen() { $name = $this->testClose(); $path = Path::join([DATAFIXTURES_DIR, 'backups', '13-21-2016-05-29_success.zip']); $tempFile = tempnam('/tmp', 'nanbando'); $this->temporaryFileSystem->createTemporaryFile()->willReturn($tempFile); $this->localFilesystem->readStream(sprintf('%s/%s.zip', $this->name, $name))->willReturn(file_get_contents($path)); $filesystem = $this->storage->open($name); $this->assertInstanceOf(Filesystem::class, $filesystem); $this->assertInstanceOf(ReadonlyAdapter::class, $filesystem->getAdapter()); $this->assertInstanceOf(ZipArchiveAdapter::class, $filesystem->getAdapter()->getAdapter()); $this->assertEquals($tempFile, $filesystem->getAdapter()->getAdapter()->getArchive()->filename); }