public function SitemapGenerator::generateSitemap in Simple XML sitemap 8.2
Wrapper method which takes links along with their options and then generates and saves the sitemap.
Parameters
array $links: All links with their multilingual versions and settings.
bool $remove_sitemap: Remove old sitemap from database before inserting the new one.
File
- src/
SitemapGenerator.php, line 133
Class
- SitemapGenerator
- Class SitemapGenerator @package Drupal\simple_sitemap
Namespace
Drupal\simple_sitemapCode
public function generateSitemap(array $links, $remove_sitemap = FALSE) {
$values = [
'id' => $remove_sitemap ? self::FIRST_CHUNK_INDEX : $this->db
->query('SELECT MAX(id) FROM {simple_sitemap}')
->fetchField() + 1,
'sitemap_string' => $this
->generateSitemapChunk($links),
'sitemap_created' => $this->time
->getRequestTime(),
];
if ($remove_sitemap) {
$this->db
->truncate('simple_sitemap')
->execute();
}
$this->db
->insert('simple_sitemap')
->fields($values)
->execute();
}