You are here

protected function SimpleSitemapStorage::getSitemapString in Simple XML sitemap 4.x

2 calls to SimpleSitemapStorage::getSitemapString()
SimpleSitemapStorage::getChunk in src/Entity/SimpleSitemapStorage.php
@todo Duplicate query.
SimpleSitemapStorage::getIndex in src/Entity/SimpleSitemapStorage.php
@todo Duplicate query.

File

src/Entity/SimpleSitemapStorage.php, line 269

Class

SimpleSitemapStorage

Namespace

Drupal\simple_sitemap\Entity

Code

protected function getSitemapString(SimpleSitemap $entity, int $id, ?bool $status) : string {
  $chunk_data = $this
    ->getChunkData($entity);
  if (!isset($chunk_data[$id])) {
    throw new SitemapNotExistsException();
  }
  if (empty($chunk_data[$id]->sitemap_string)) {
    $query = $this->database
      ->select('simple_sitemap', 's')
      ->fields('s', [
      'sitemap_string',
    ])
      ->condition('status', $status)
      ->condition('id', $id);
    $chunk_data[$id]->sitemap_string = $query
      ->execute()
      ->fetchField();
  }
  return $chunk_data[$id]->sitemap_string;
}