You are here

public function ContentHubExportQueue::processQueueItems in Acquia Content Hub 8.2

Process all queue items with batch API.

File

modules/acquia_contenthub_publisher/src/ContentHubExportQueue.php, line 70

Class

ContentHubExportQueue
Implements an Export Queue for Content Hub.

Namespace

Drupal\acquia_contenthub_publisher

Code

public function processQueueItems() {

  // Create batch which collects all the specified queue items and process
  // them one after another.
  $batch = [
    'title' => $this
      ->t("Process Content Hub Export Queue"),
    'operations' => [],
    'finished' => [
      [
        $this,
        'batchFinished',
      ],
      [],
    ],
  ];

  // Count number of the items in this queue, create enough batch operations.
  for ($i = 0; $i < $this
    ->getQueueCount(); $i++) {

    // Create batch operations.
    $batch['operations'][] = [
      [
        $this,
        'batchProcess',
      ],
      [],
    ];
  }

  // Adds the batch sets.
  batch_set($batch);
}