protected function QueueListCommand::execute in Advanced Queue 8
File
- src/
Command/ QueueListCommand.php, line 58
Class
- QueueListCommand
- Queue list command.
Namespace
Drupal\advancedqueue\CommandCode
protected function execute(InputInterface $input, OutputInterface $output) {
$count_labels = [
Job::STATE_QUEUED => $this
->trans('commands.advancedqueue.queue.list.counts.queued'),
Job::STATE_PROCESSING => $this
->trans('commands.advancedqueue.queue.list.counts.processing'),
Job::STATE_SUCCESS => $this
->trans('commands.advancedqueue.queue.list.counts.success'),
Job::STATE_FAILURE => $this
->trans('commands.advancedqueue.queue.list.counts.failure'),
];
$queue_storage = $this->entityTypeManager
->getStorage('advancedqueue_queue');
$rows = [];
foreach ($queue_storage
->loadMultiple() as $queue) {
/** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */
$jobs = [];
foreach ($queue
->getBackend()
->countJobs() as $state => $count) {
$jobs[] = sprintf($count_labels[$state], $count);
}
$rows[] = [
'id' => $queue
->id(),
'label' => $queue
->label(),
'jobs' => implode(' | ', $jobs),
];
}
$io = new DrupalStyle($input, $output);
$io
->table([
$this
->trans('commands.advancedqueue.queue.list.table-headers.id'),
$this
->trans('commands.advancedqueue.queue.list.table-headers.label'),
$this
->trans('commands.advancedqueue.queue.list.table-headers.jobs'),
], $rows, 'default');
}