You are here

public function Manager::queueBatch in Taxonomy Term Depth 8

Same name and namespace in other branches
  1. 8.2 src/QueueManager/Manager.php \Drupal\taxonomy_term_depth\QueueManager\Manager::queueBatch()
1 call to Manager::queueBatch()
Manager::queueBatchMissing in src/QueueManager/Manager.php

File

src/QueueManager/Manager.php, line 47
Manages queue operations.

Class

Manager

Namespace

Drupal\taxonomy_term_depth\QueueManager

Code

public function queueBatch($queue_all = TRUE) {
  $query = $this
    ->getTermsQuery();
  if (!$queue_all) {
    $query
      ->condition((new Condition())
      ->condition('td.depth_level', '', 'IS NULL')
      ->condition('td.depth', '', 'IS NULL'));
  }
  else {

    // Delete queue if have one.
    $this
      ->clear();
  }
  $ids = [];
  foreach ($query
    ->execute() as $row) {
    if (count($ids) >= static::BATCH_COUNT) {
      $this
        ->queueByIds($ids);
      $ids = [];
    }
    $ids[] = $row->tid;
  }

  // Queue remaining items.
  $this
    ->queueByIds($ids);
  return TRUE;
}