You are here

protected function SimplesitemapSitemapsForm::fetchSitemapInstanceInfo in Simple XML sitemap 8.3

@todo Implement SitemapGeneratorBase::isPublished() per sitemap instead or at least return a constant.

Return value

array Array of sitemap statuses and link counts keyed by variant name. Status values: 0: Instance is unpublished 1: Instance is published 2: Instance is published but is being regenerated

1 call to SimplesitemapSitemapsForm::fetchSitemapInstanceInfo()
SimplesitemapSitemapsForm::buildForm in src/Form/SimplesitemapSitemapsForm.php
Form constructor.

File

src/Form/SimplesitemapSitemapsForm.php, line 209

Class

SimplesitemapSitemapsForm
Class SimplesitemapSitemapsForm @package Drupal\simple_sitemap\Form

Namespace

Drupal\simple_sitemap\Form

Code

protected function fetchSitemapInstanceInfo() {
  $results = $this->db
    ->query('SELECT type, status, SUM(link_count) as link_count FROM {simple_sitemap} GROUP BY type, status ORDER BY type, status ASC')
    ->fetchAll();
  $instance_info = [];
  foreach ($results as $i => $result) {
    $instance_info[$result->type] = [
      'status' => isset($instance_info[$result->type]) ? $result->status + 1 : (int) $result->status,
      'link_count' => (int) $result->link_count,
    ];
  }
  return $instance_info;
}