Пример #1
0
 /**
  * @param File[] $files
  *
  * @return File[]
  */
 public function compress($files)
 {
     $compressedLocation = $this->filesHelper->createTemporaryFile('compressed.' . $this->getExtension());
     $compressedCommand = $this->createCommand($files, $compressedLocation);
     shell_exec($compressedCommand);
     if (file_exists($compressedLocation) && filesize($compressedLocation) > 0) {
         $compressedFile = new File($compressedLocation);
         return [$compressedFile];
     }
     return [];
 }
Пример #2
0
 /**
  * Returns the list of files generated for this dump.
  *
  * @param DatabaseSettings $settings
  *
  * @return File[]
  */
 public function dump(DatabaseSettings $settings)
 {
     $files = [];
     if ($settings->wantsOneDumpPerTable()) {
         foreach ($this->getTablesToExport($settings) as $table) {
             $dumpLocation = $this->filesHelper->createTemporaryFile($settings->getDbName() . '.' . $table . '.sql');
             $dumpCommand = $this->createCommand($settings, $dumpLocation, $table);
             $this->shellExecutor->execute($dumpCommand);
             if (file_exists($dumpLocation) && filesize($dumpLocation) > 0) {
                 $files[] = new File($dumpLocation);
             }
         }
     } else {
         $dumpLocation = $this->filesHelper->createTemporaryFile($settings->getDbName() . '.sql');
         $dumpCommand = $this->createCommand($settings, $dumpLocation);
         $this->shellExecutor->execute($dumpCommand);
         if (file_exists($dumpLocation) && filesize($dumpLocation) > 0) {
             $files[] = new File($dumpLocation);
         }
     }
     return $files;
 }