You are here

private function Simplesitemap::save_sitemap in Simple XML sitemap 8

Saves the sitemap to the db.

1 call to Simplesitemap::save_sitemap()
Simplesitemap::generate_sitemap in src/Simplesitemap.php
Generates the sitemap for all languages and saves it to the db.

File

src/Simplesitemap.php, line 186
Contains \Drupal\simplesitemap\Simplesitemap.

Class

Simplesitemap
Simplesitemap class.

Namespace

Drupal\simplesitemap

Code

private function save_sitemap() {
  db_truncate('simplesitemap')
    ->execute();
  $values = array();
  foreach ($this->sitemap as $chunk_id => $chunk_data) {
    $values[] = array(
      'id' => $chunk_id,
      'sitemap_string' => $chunk_data->sitemap_string,
      'sitemap_created' => $chunk_data->sitemap_created,
    );
  }
  $query = db_insert('simplesitemap')
    ->fields(array(
    'id',
    'sitemap_string',
    'sitemap_created',
  ));
  foreach ($values as $record) {
    $query
      ->values($record);
  }
  $query
    ->execute();
}