Skip to content

Commit 9fed23b

Browse files
authored
adding ability to zip export of multiple tables (#299)
AppVeyor fail is unrelated
1 parent c629081 commit 9fed23b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/Command/ExportCommand.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
118118

119119
/** @var Zip $zipArchive */
120120
$zipArchive = (new Archive())->getAdapter('zip');
121+
122+
$filenames = [];
123+
$zipFilesArray = [];
121124
}
122125

123126
foreach ($tables as $table) {
@@ -137,15 +140,21 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in
137140
File::write($filename, $data);
138141

139142
if ($zip) {
140-
$zipFilesArray = [['name' => $table . '.xml', 'data' => $data]];
141-
$zipArchive->create($zipFile, $zipFilesArray);
142-
File::delete($filename);
143+
$zipFilesArray[] = ['name' => $table . '.xml', 'data' => $data];
144+
$filenames[] = $filename;
143145
}
144146

145147
$symfonyStyle->text(sprintf('Exported data for %s in %d seconds', $table, round(microtime(true) - $taskTime, 3)));
146148
}
147149
}
148150

151+
if ($zip) {
152+
$zipArchive->create($zipFile, $zipFilesArray);
153+
foreach ($filenames as $fname) {
154+
File::delete($fname);
155+
}
156+
}
157+
149158
$symfonyStyle->success(sprintf('Export completed in %d seconds', round(microtime(true) - $totalTime, 3)));
150159

151160
return 0;

0 commit comments

Comments
 (0)