You are here

public function ContentHubImportQueue::batchProcess in Acquia Content Hub 8.2

Process the batch.

The batch worker will run through the queued items and process them according to their queue method.

Parameters

mixed $context: The batch context.

File

modules/acquia_contenthub_subscriber/src/ContentHubImportQueue.php, line 81

Class

ContentHubImportQueue
Implements an Import Queue for entities.

Namespace

Drupal\acquia_contenthub_subscriber

Code

public function batchProcess(&$context) {
  $queueWorker = $this->queueManager
    ->createInstance('acquia_contenthub_subscriber_import');
  if ($item = $this->queue
    ->claimItem()) {
    try {
      $queueWorker
        ->processItem($item->data);
      $this->queue
        ->deleteItem($item);
    } catch (SuspendQueueException $exception) {
      $context['errors'][] = $exception
        ->getMessage();
      $context['success'] = FALSE;
      $this->queue
        ->releaseItem($item);
    } catch (EntityStorageException $exception) {
      $context['errors'][] = $exception
        ->getMessage();
      $context['success'] = FALSE;
      $this->queue
        ->releaseItem($item);
    }
  }
}