simple_sitemap.drush.inc 1.18 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
 */

gbyte.co's avatar
gbyte.co committed
8 9
use Drupal\simple_sitemap\Queue\QueueWorker;

10 11 12
/**
 * Implements hook_drush_command().
 */
gbyte.co's avatar
gbyte.co committed
13
function simple_sitemap_drush_command() {
14
  $items['simple-sitemap-generate'] = [
15
    'description' => 'Regenerate all XML sitemap variants or continue generation.',
gbyte.co's avatar
gbyte.co committed
16
    'callback' => 'drush_simple_sitemap_generate',
gbyte.co's avatar
gbyte.co committed
17
    'drupal dependencies' => ['simple_sitemap'],
18
    'aliases' => ['ssg'],
gbyte.co's avatar
gbyte.co committed
19
  ];
20

21
  $items['simple-sitemap-rebuild-queue'] = [
22
    'description' => 'Queue all sitemap variants for regeneration.',
23 24
    'callback' => 'drush_simple_sitemap_rebuild_queue',
    'drupal dependencies' => ['simple_sitemap'],
25
    'aliases' => ['ssr'],
26 27
  ];

28 29 30 31 32 33
  return $items;
}

/**
 * Callback function for hook_drush_command().
 *
34
 * Regenerate the XML sitemaps according to the module settings.
35
 */
gbyte.co's avatar
gbyte.co committed
36
function drush_simple_sitemap_generate() {
gbyte.co's avatar
gbyte.co committed
37
  \Drupal::service('simple_sitemap.generator')->generateSitemap(QueueWorker::GENERATE_TYPE_DRUSH);
38
}
39 40 41 42 43 44 45 46 47

/**
 * 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();
}