You are here

protected function SocialDrupalContext::processQueue in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  2. 8.3 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  3. 8.4 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  4. 8.5 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  5. 8.7 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  6. 8.8 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  7. 10.3.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  8. 10.0.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  9. 10.1.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()
  10. 10.2.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::processQueue()

Process queue items.

Parameters

bool $just_delete: If set to TRUE, it doesn't process the items, but simply deletes them.

2 calls to SocialDrupalContext::processQueue()
SocialDrupalContext::iEmptyTheQueue in tests/behat/features/bootstrap/SocialDrupalContext.php
@When I empty the queue
SocialDrupalContext::iWaitForTheQueueToBeEmpty in tests/behat/features/bootstrap/SocialDrupalContext.php
@When I wait for the queue to be empty

File

tests/behat/features/bootstrap/SocialDrupalContext.php, line 173

Class

SocialDrupalContext
Provides pre-built step definitions for interacting with Open Social.

Namespace

Drupal\social\Behat

Code

protected function processQueue($just_delete = FALSE) {
  $workerManager = \Drupal::service('plugin.manager.queue_worker');

  /** @var Drupal\Core\Queue\QueueFactory; $queue */
  $queue = \Drupal::service('queue');
  for ($i = 0; $i < 20; $i++) {
    foreach ($workerManager
      ->getDefinitions() as $name => $info) {

      /** @var Drupal\Core\Queue\QueueInterface $worker */
      $worker = $queue
        ->get($name);

      /** @var \Drupal\Core\Queue\QueueWorkerInterface $queue_worker */
      $queue_worker = $workerManager
        ->createInstance($name);
      if ($worker
        ->numberOfItems() > 0) {
        while ($item = $worker
          ->claimItem()) {

          // If we don't just delete them, process the item first.
          if ($just_delete === FALSE) {
            $queue_worker
              ->processItem($item->data);
          }
          $worker
            ->deleteItem($item);
        }
      }
    }
  }
}