/** * @inheritdoc * * @LoggerAware() */ public function process(IndentedLoggerInterface $output, ContainerAwareCommand $command = null) { $this->logger->debug('Processing queue'); $output->write('Processing queue... '); $jobs = $this->repoJob->getLastActive(50); $this->toggleJobsLocks($jobs, true); $amount = 0; $skipped = 0; $failed = 0; foreach ($jobs as $job) { try { $this->em->refresh($job); if (!$job->isActive()) { continue; } $result = $this->processJob($job); if ($result === true) { $amount++; } elseif ($result === -1) { $skipped++; } else { $failed++; } } catch (\Exception $e) { $output->write('finished with exception. '); break; } } $this->toggleJobsLocks($jobs, false); $output->writeln(sprintf('%s processed, %s skipped, %s failed', (string) $amount, (string) $skipped, (string) $failed)); $this->logger->debug('finished'); if (isset($e)) { throw $e; } }
/** * {@inheritdoc} */ public function process(IndentedLoggerInterface $logger, ContainerAwareCommand $command = null, $class = null, $noStuff = false) { uasort($this->providers, function ($a, $b) { if ($a['priority'] == $b['priority']) { return 0; } return $a['priority'] > $b['priority'] ? -1 : 1; }); if ($class) { if (!isset($this->providers[$class])) { throw new ProviderNotFoundException('Provider not found: ' . $class); } $provider = $this->providers[$class]; $list = [$class => $provider]; } else { $list = $this->providers; } foreach ($list as $class => $row) { if ($class == 'stuff' && $noStuff) { $logger->writeln('Stuff skipped'); continue; } $provider = $row['provider']; /** @var CompileProviderInterface $provider */ $logger->write('Processing ' . $class . ': '); $provider->process($logger, $command); } }