simple_sitemap.drush.inc 1.04 KB
Newer Older
1
<?php
gbyte.co's avatar
gbyte.co committed
2

3 4
/**
 * @file
gbyte.co's avatar
gbyte.co committed
5
 * Drush (< 9) integration.
6 7 8 9 10
 */

/**
 * Implements hook_drush_command().
 */
gbyte.co's avatar
gbyte.co committed
11
function simple_sitemap_drush_command() {
12
  $items['simple_sitemap-generate'] = [
13
    'description' => 'Regenerate the XML sitemaps according to the module settings.',
gbyte.co's avatar
gbyte.co committed
14
    'callback' => 'drush_simple_sitemap_generate',
15 16
    'drupal dependencies' => ['simple_sitemap'],
  ];
17 18 19 20 21 22 23

  $items['simple_sitemap-rebuild-queue'] = [
    'description' => 'Rebuild the sitemap queue for all sitemap variants.',
    'callback' => 'drush_simple_sitemap_rebuild_queue',
    'drupal dependencies' => ['simple_sitemap'],
  ];

24 25 26 27 28 29
  return $items;
}

/**
 * Callback function for hook_drush_command().
 *
30
 * Regenerate the XML sitemaps.
31
 */
gbyte.co's avatar
gbyte.co committed
32
function drush_simple_sitemap_generate() {
gbyte.co's avatar
gbyte.co committed
33
  \Drupal::service('simple_sitemap.generator')->generateSitemap('drush');
34
}
35 36 37 38 39 40 41 42 43

/**
 * Callback function for hook_drush_command().
 *
 * Rebuild the sitemap queue for all sitemap variants.
 */
function drush_simple_sitemap_rebuild_queue() {
  \Drupal::service('simple_sitemap.generator')->rebuildQueue();
}