You are here

simple_sitemap_views.module in Simple XML sitemap (Views integration) 8

File

simple_sitemap_views.module
View source
<?php

/**
 * @file
 * Contains simple_sitemap_views.module.
 */

/**
 * Implements hook_cron().
 */
function simple_sitemap_views_cron() {

  // The task queue of garbage collection in the index.
  $queue = \Drupal::queue('simple_sitemap_views_garbage_collector');

  // Check that the queue is empty.
  if (!$queue
    ->numberOfItems()) {

    // Get identifiers of indexed views.
    $query = \Drupal::database()
      ->select('simple_sitemap_views', 'ssv');
    $query
      ->addField('ssv', 'view_id');
    $query
      ->distinct();
    $result = $query
      ->execute()
      ->fetchCol();

    // Create a garbage collection task.
    foreach ($result as $view_id) {
      $queue
        ->createItem([
        'view_id' => $view_id,
      ]);
    }
  }
}

Functions

Namesort descending Description
simple_sitemap_views_cron Implements hook_cron().