You are here

public function Manager::queueBatch in Taxonomy Term Depth 8.2

Same name and namespace in other branches
  1. 8 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 46

Class

Manager

Namespace

Drupal\taxonomy_term_depth\QueueManager

Code

public function queueBatch($queue_all = TRUE) {
  $query = $this
    ->getTermsQuery();
  if (!$queue_all) {
    $query
      ->isNull('td.depth_level');
  }
  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;
}