public function AdvancedQueueCommands::listQueues in Advanced Queue 8
List queues.
@field-labels id: ID label: Label jobs: Jobs
@command advancedqueue:queue:list
Return value
\Consolidation\OutputFormatters\StructuredData\RowsOfFields The output.
File
- src/
Commands/ AdvancedQueueCommands.php, line 88
Class
- AdvancedQueueCommands
- Declares AdvancedQueue module Drush commands.
Namespace
Drupal\advancedqueue\CommandsCode
public function listQueues() {
$count_labels = [
Job::STATE_QUEUED => new TranslatableMarkup('Queued'),
Job::STATE_PROCESSING => new TranslatableMarkup('Processing'),
Job::STATE_SUCCESS => new TranslatableMarkup('Success'),
Job::STATE_FAILURE => new TranslatableMarkup('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('%s: %s', $count_labels[$state], $count);
}
$rows[] = [
'id' => $queue
->id(),
'label' => $queue
->label(),
'jobs' => implode(' | ', $jobs),
];
}
return new RowsOfFields($rows);
}