You are here

private function SitemapWarmer::parseSitemaps in Warmer 2.x

Same name and namespace in other branches
  1. 8 modules/warmer_cdn/src/Plugin/warmer/SitemapWarmer.php \Drupal\warmer_cdn\Plugin\warmer\SitemapWarmer::parseSitemaps()

Parse and cache the configured sitemaps.

Return value

string[] The URLs from parsing the sitemap.

1 call to SitemapWarmer::parseSitemaps()
SitemapWarmer::buildIdsBatch in modules/warmer_cdn/src/Plugin/warmer/SitemapWarmer.php
Builds the next batch of IDs based on a position cursor.

File

modules/warmer_cdn/src/Plugin/warmer/SitemapWarmer.php, line 199

Class

SitemapWarmer
The cache warmer for the built-in entity cache.

Namespace

Drupal\warmer_cdn\Plugin\warmer

Code

private function parseSitemaps() {
  if (isset($this->urlCollection)) {
    return $this->urlCollection;
  }
  $configuration = $this
    ->getConfiguration();
  $sitemaps = empty($configuration['sitemaps']) ? [] : $configuration['sitemaps'];
  $sitemap_urls = array_map([
    $this,
    'resolveUri',
  ], $sitemaps);
  array_map([
    $this,
    'parseSitemap',
  ], $sitemap_urls);
  $min_priority = empty($configuration['minPriority']) ? 0 : $configuration['minPriority'];
  $min_priority = floatval($min_priority);

  // Only keep the URLs with enough priority.
  $parsed_urls = array_filter($this->sitemapParser
    ->getURLs(), function (array $tags) use ($min_priority) {
    return $tags['priority'] >= $min_priority;
  });
  $this->urlCollection = array_keys($parsed_urls);
  return $this->urlCollection;
}