You are here

public function QueueListBuilder::buildRow in Advanced Queue 8

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

src/QueueListBuilder.php, line 26

Class

QueueListBuilder
Defines the list builder for queues.

Namespace

Drupal\advancedqueue

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\advancedqueue\Entity\QueueInterface $entity */
  $count_labels = [
    Job::STATE_QUEUED => $this
      ->t('Queued'),
    Job::STATE_PROCESSING => $this
      ->t('Processing'),
    Job::STATE_SUCCESS => $this
      ->t('Success'),
    Job::STATE_FAILURE => $this
      ->t('Failure'),
  ];
  $jobs = [];
  foreach ($entity
    ->getBackend()
    ->countJobs() as $state => $count) {
    $jobs[] = sprintf('%s: %s', $count_labels[$state], $count);
  }
  $row['label'] = $entity
    ->label();
  $row['jobs'] = implode(' | ', $jobs);
  return $row + parent::buildRow($entity);
}