public function SimpleSitemapStorage::publish in Simple XML sitemap 4.x
File
- src/
Entity/ SimpleSitemapStorage.php, line 166
Class
Namespace
Drupal\simple_sitemap\EntityCode
public function publish(SimpleSitemap $entity) : void {
$unpublished_chunk = $this->database
->query('SELECT MAX(id) FROM {simple_sitemap} WHERE type = :type AND status = :status', [
':type' => $entity
->id(),
':status' => self::SITEMAP_UNPUBLISHED,
])
->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->database
->delete('simple_sitemap')
->condition('type', $entity
->id())
->condition('status', self::SITEMAP_PUBLISHED)
->execute();
$this->database
->query('UPDATE {simple_sitemap} SET status = :status WHERE type = :type', [
':type' => $entity
->id(),
':status' => self::SITEMAP_PUBLISHED,
]);
}
}