You are here

public function XmlSitemapGenerator::regenerateBatchFinished in XML sitemap 8

Same name and namespace in other branches
  1. 2.x src/XmlSitemapGenerator.php \Drupal\xmlsitemap\XmlSitemapGenerator::regenerateBatchFinished()

Batch callback; sitemap regeneration finished.

Parameters

bool $success: Checks if regeneration batch process was successful.

array $results: Results for the regeneration process.

array $operations: Operations performed.

int $elapsed: Elapsed. Time elapsed.

Overrides XmlSitemapGeneratorInterface::regenerateBatchFinished

File

src/XmlSitemapGenerator.php, line 476

Class

XmlSitemapGenerator
XmlSitemap generator service class.

Namespace

Drupal\xmlsitemap

Code

public function regenerateBatchFinished($success, array $results, array $operations, $elapsed) {
  if ($success && $this->state
    ->get('xmlsitemap_regenerate_needed') == FALSE) {
    $this->state
      ->set('xmlsitemap_generated_last', $this->time
      ->getRequestTime());
    $this->messenger
      ->addStatus($this
      ->t('The sitemaps were regenerated.'));

    // Show a watchdog message that the sitemap was regenerated.
    $this->logger
      ->notice('Finished XML sitemap generation in @elapsed. Memory usage: @memory-peak.', [
      '@elapsed' => $elapsed,
      '@memory-peak' => format_size(memory_get_peak_usage(TRUE)),
    ]);
  }
  else {
    $this->messenger
      ->addError($this
      ->t('The sitemaps were not successfully regenerated.'));
  }
}