You are here

protected function QueueWorker::generateVariantChunksFromResults in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x src/Queue/QueueWorker.php \Drupal\simple_sitemap\Queue\QueueWorker::generateVariantChunksFromResults()

Parameters

bool $complete:

Throws

\Drupal\Component\Plugin\Exception\PluginException

1 call to QueueWorker::generateVariantChunksFromResults()
QueueWorker::generateSitemap in src/Queue/QueueWorker.php

File

src/Queue/QueueWorker.php, line 324

Class

QueueWorker

Namespace

Drupal\simple_sitemap\Queue

Code

protected function generateVariantChunksFromResults($complete = FALSE) {
  if (!empty($this->results)) {
    $processed_results = $this->results;
    $this->moduleHandler
      ->alter('simple_sitemap_links', $processed_results, $this->variantProcessedNow);
    $this->processedResults = array_merge($this->processedResults, $processed_results);
    $this->results = [];
  }
  if (empty($this->processedResults)) {
    return;
  }
  $generator = $this->manager
    ->getSitemapGenerator($this->generatorProcessedNow)
    ->setSitemapVariant($this->variantProcessedNow)
    ->setSettings($this->generatorSettings);
  if (!empty($this->maxLinks)) {
    foreach (array_chunk($this->processedResults, $this->maxLinks, TRUE) as $chunk_links) {
      if ($complete || count($chunk_links) === $this->maxLinks) {
        $generator
          ->generate($chunk_links);
        $this->processedResults = array_diff_key($this->processedResults, $chunk_links);
      }
    }
  }
  else {
    $generator
      ->generate($this->processedResults);
    $this->processedResults = [];
  }
}