Пример #1
0
 /**
  * @param string $type of compression: "gz" | "gzip" | "none" | null
  */
 public function setCompression($type)
 {
     $this->compressor = AbstractCompressor::create($type);
 }
Пример #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectDbSettings($output);
     $this->writeSection($output, 'Import MySQL Database');
     $dbHelper = $this->getHelper('database');
     $fileName = $this->checkFilename($input);
     $compressor = AbstractCompressor::create($input->getOption('compression'));
     // create import command
     $exec = $compressor->getDecompressingCommand('mysql ' . $dbHelper->getMysqlClientToolConnectionString(), $fileName);
     if ($input->getOption('only-command')) {
         $output->writeln($exec);
         return;
     } else {
         if ($input->getOption('only-if-empty') && count($dbHelper->getTables()) > 0) {
             $output->writeln('<comment>Skip import. Database is not empty</comment>');
             return;
         }
     }
     if ($input->getOption('optimize')) {
         if ($input->getOption('compression')) {
             throw new Exception('Options --compression and --optimize are not compatible');
         }
         $output->writeln('<comment>Optimizing <info>' . $fileName . '</info> to temporary file');
         $fileName = $this->optimize($fileName);
     }
     if ($input->getOption('drop')) {
         $dbHelper->dropDatabase($output);
         $dbHelper->createDatabase($output);
     }
     if ($input->getOption('drop-tables')) {
         $dbHelper->dropTables($output);
     }
     $this->doImport($output, $fileName, $exec);
     if ($input->getOption('optimize')) {
         unlink($fileName);
     }
 }
 /**
  * @param string $type
  * @return AbstractCompressor
  * @deprecated Since 1.1.12; use AbstractCompressor::create() instead
  */
 protected function getCompressor($type)
 {
     return AbstractCompressor::create($type);
 }