public function fetch(Persistence\Query $queryObject, $hydrationMode = AbstractQuery::HYDRATE_OBJECT) { try { return $queryObject->fetch($this, $hydrationMode); } catch (\Exception $e) { throw $this->handleQueryException($e, $queryObject); } }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $lang = $input->getArgument(self::LANGUAGE_ARGUMENT); /** @var Language $language */ if (($language = $this->findLanguage($lang)) === NULL) { $output->writeln("<error>Unknown language {$lang} given!"); return 1; } $output->writeln('<comment>Finding scenarios...</comment>'); $scenarios = $this->scenariosRepository->fetch(new ScreenplayExportQuery($language)); $count = $scenarios->getTotalCount(); $output->writeln("<comment>Found {$count} scenarios</comment>"); $progressBar = new ProgressBar($output); $progressBar->start($count); for ($i = 0; $i <= $count; $i += self::BATCH_SIZE) { $scenarios->applyPaging($i, self::BATCH_SIZE); $scenariosArray = []; /** @var Screenplay $screenplay */ foreach ($scenarios as $screenplay) { $scenariosArray[] = $screenplay; $progressBar->advance(); } $this->screenplayProducer->publish($scenariosArray); } $progressBar->finish(); $output->writeln(""); $output->writeln("<info>Finish</info>"); }