function Batch::getAllItems

Same name in other branches
  1. 9 core/lib/Drupal/Core/Queue/Batch.php \Drupal\Core\Queue\Batch::getAllItems()
  2. 8.9.x core/lib/Drupal/Core/Queue/Batch.php \Drupal\Core\Queue\Batch::getAllItems()
  3. 11.x core/lib/Drupal/Core/Queue/Batch.php \Drupal\Core\Queue\Batch::getAllItems()

Retrieves all remaining items in the queue.

This is specific to Batch API and is not part of the \Drupal\Core\Queue\QueueInterface.

Return value

array An array of queue items.

File

core/lib/Drupal/Core/Queue/Batch.php, line 50

Class

Batch
Defines a batch queue handler used by the Batch API.

Namespace

Drupal\Core\Queue

Code

public function getAllItems() {
    $result = [];
    try {
        $items = $this->connection
            ->query('SELECT [data] FROM {queue} q WHERE [name] = :name ORDER BY [item_id] ASC', [
            ':name' => $this->name,
        ])
            ->fetchAll();
        foreach ($items as $item) {
            $result[] = unserialize($item->data);
        }
    } catch (\Exception $e) {
        $this->catchException($e);
    }
    return $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.