You are here

protected function QueueProcessCommand::execute in Advanced Queue 8

File

src/Command/QueueProcessCommand.php, line 68

Class

QueueProcessCommand
Class ProcessQueueCommand.

Namespace

Drupal\advancedqueue\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $queue_id = $input
    ->getArgument('queue_id');
  $queue_storage = $this->entityTypeManager
    ->getStorage('advancedqueue_queue');

  /** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */
  $queue = $queue_storage
    ->load($queue_id);
  if (!$queue) {
    $message = $this
      ->trans('commands.advancedqueue.queue.process.messages.not-found');
    throw new \RuntimeException(sprintf($message, $queue_id));
  }
  $io = new DrupalStyle($input, $output);
  $start = microtime(TRUE);
  $num_processed = $this->processor
    ->processQueue($queue);
  $elapsed = microtime(TRUE) - $start;
  $io
    ->success(sprintf($this
    ->trans('commands.advancedqueue.queue.process.messages.finished'), $num_processed, $queue
    ->label(), round($elapsed, 2)));
}