コード例 #1
0
ファイル: ImportCommand.php プロジェクト: devour-php/devour
 protected function doExecute(\SplObjectStorage $process_group, ImporterInterface $importer, SourceInterface $source, $num_processes, $config)
 {
     $script_path = DEVOUR_COMMAND_START_DIR . '/batch.php';
     do {
         $this->limitProcess($process_group, $num_processes);
         if ($importer->getTransporter()->runInNewProcess()) {
             $args = ['php', $script_path, 'transport', $config, $source];
             $builder = new ProcessBuilder($args);
             $process = $builder->getProcess();
             $process->start();
             $process_group->attach($process);
             return;
         } else {
             $stream = $importer->transport($source);
             $args = ['php', $script_path, 'parse', $config, $source, $stream->getMetadata('uri')];
         }
         $builder = new ProcessBuilder($args);
         $process = $builder->getProcess();
         $process->start();
         $process_group->attach($process);
     } while ($importer->getTransporter()->progress($source) != ProgressInterface::COMPLETE);
 }
コード例 #2
0
ファイル: ImporterBuilder.php プロジェクト: devour-php/devour
 /**
  * Returns the newly minted importer.
  *
  * This method must be called last, and only once.
  *
  * @return \Devour\Importer\ImporterInterface
  *   The newly configured importer.
  *
  * @throws \LogicException
  *   Thrown if called more than once.
  */
 public function build()
 {
     if ($this->hasBeenExecuted) {
         throw new \LogicException('Builders can only be used once.');
     }
     $this->hasBeenExecuted = TRUE;
     // Hello old faithful.
     if (!$this->importer) {
         $this->setImporter(new Importer());
     }
     $this->replayCommands();
     if (!$this->importer->getLogger()) {
         $this->doSetLogger(new NullLogger());
     }
     $this->importer->validate();
     // Since this is potentially a long running process, we need to make an
     // effort to clean up after ourselves.
     $importer = $this->importer;
     unset($this->importer, $this->commands, $this->clients);
     return $importer;
 }