You are here

public static function BatchTrait::doBatchGenerateSitemap in Simple XML sitemap 8.3

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

@todo Variants into generateSitemap().

Parameters

$context:

Throws

\Drupal\Component\Plugin\Exception\PluginException

1 call to BatchTrait::doBatchGenerateSitemap()
Tester::doBatchGenerateSitemap in tests/scripts/performance_test.php

File

src/Queue/BatchTrait.php, line 60

Class

BatchTrait

Namespace

Drupal\simple_sitemap\Queue

Code

public static function doBatchGenerateSitemap(&$context) {

  /** @var \Drupal\simple_sitemap\Queue\QueueWorker $queue_worker */
  $queue_worker = \Drupal::service('simple_sitemap.queue_worker');
  $queue_worker
    ->generateSitemap();
  $processed_element_count = $queue_worker
    ->getProcessedElementCount();
  $original_element_count = $queue_worker
    ->getInitialElementCount();
  $context['message'] = t('@indexed out of @total total queue items have been processed.', [
    '@indexed' => $processed_element_count,
    '@total' => $original_element_count,
  ]);
  $context['finished'] = $original_element_count > 0 ? $processed_element_count / $original_element_count : 1;
}