You are here

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

File

src/Entity/SimpleSitemapStorage.php, line 184

Class

SimpleSitemapStorage

Namespace

Drupal\simple_sitemap\Entity

Code

public function addChunk(SimpleSitemapInterface $entity, string $xml, $link_count) : void {
  $highest_delta = $this->database
    ->query('SELECT MAX(delta) FROM {simple_sitemap} WHERE type = :type AND status = :status', [
    ':type' => $entity
      ->id(),
    ':status' => self::SITEMAP_UNPUBLISHED,
  ])
    ->fetchField();
  $this->database
    ->insert('simple_sitemap')
    ->fields([
    'delta' => NULL === $highest_delta ? self::SITEMAP_CHUNK_FIRST_DELTA : $highest_delta + 1,
    'type' => $entity
      ->id(),
    'sitemap_string' => $xml,
    'sitemap_created' => $this->time
      ->getRequestTime(),
    'status' => 0,
    'link_count' => $link_count,
  ])
    ->execute();
}