You are here

public function SimpleSitemapStorage::generateIndex in Simple XML sitemap 4.x

File

src/Entity/SimpleSitemapStorage.php, line 198

Class

SimpleSitemapStorage

Namespace

Drupal\simple_sitemap\Entity

Code

public function generateIndex(SimpleSitemapInterface $entity, string $xml) : void {
  $this->database
    ->merge('simple_sitemap')
    ->keys([
    'delta' => self::SITEMAP_INDEX_DELTA,
    'type' => $entity
      ->id(),
    'status' => 0,
  ])
    ->insertFields([
    'delta' => self::SITEMAP_INDEX_DELTA,
    'type' => $entity
      ->id(),
    'sitemap_string' => $xml,
    'sitemap_created' => $this->time
      ->getRequestTime(),
    'status' => 0,
  ])
    ->updateFields([
    'sitemap_string' => $xml,
    'sitemap_created' => $this->time
      ->getRequestTime(),
  ])
    ->execute();
}