You are here

protected function UrlGeneratorBase::processSegment in Simple XML sitemap 8.2

1 call to UrlGeneratorBase::processSegment()
UrlGeneratorBase::generate in src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php
Called by batch.

File

src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php, line 331

Class

UrlGeneratorBase
Class UrlGeneratorBase @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function processSegment() {
  if ($this
    ->isBatch()) {
    $this
      ->setProgressInfo();
  }
  if (!empty($max_links = $this->batchSettings['max_links']) && count($this
    ->getBatchResults()) >= $max_links) {
    foreach (array_chunk($this
      ->getBatchResults(), $max_links) as $chunk_links) {
      if (count($chunk_links) == $max_links) {

        // Generate sitemap.
        $this->sitemapGenerator
          ->setSettings([
          'excluded_languages' => $this->batchSettings['excluded_languages'],
        ])
          ->generateSitemap($chunk_links, empty($this
          ->getChunkCount()));

        // Update chunk count info.
        $this
          ->setChunkCount(empty($this
          ->getChunkCount()) ? 1 : $this
          ->getChunkCount() + 1);

        // Remove links from result array that have been generated.
        $this
          ->setBatchResults(array_slice($this
          ->getBatchResults(), count($chunk_links)));
      }
    }
  }
}