public function SitemapGeneratorBase::publish in Simple XML sitemap 8.3
Return value
$this
Overrides SitemapGeneratorInterface::publish
File
- src/
Plugin/ simple_sitemap/ SitemapGenerator/ SitemapGeneratorBase.php, line 281
Class
- SitemapGeneratorBase
- Class SitemapGeneratorBase @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
Namespace
Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGeneratorCode
public function publish() {
$unpublished_chunk = $this->db
->query('SELECT MAX(id) FROM {simple_sitemap} WHERE type = :type AND status = :status', [
':type' => $this->sitemapVariant,
':status' => 0,
])
->fetchField();
// Only allow publishing a sitemap variant if there is an unpublished
// sitemap variant, as publishing involves deleting the currently published
// variant.
if (FALSE !== $unpublished_chunk) {
$this
->remove('published');
$this->db
->query('UPDATE {simple_sitemap} SET status = :status WHERE type = :type', [
':type' => $this->sitemapVariant,
':status' => 1,
]);
}
return $this;
}