simple_sitemap.drush.inc 1.18 KB
Newer Older
1
<?php
Pawel G's avatar
Pawel G committed
2

3 4
/**
 * @file
Pawel G's avatar
Pawel G committed
5
 * Drush (< 9) integration.
6 7
 */

Pawel G's avatar
Pawel G committed
8 9
use Drupal\simple_sitemap\Queue\QueueWorker;

10 11 12
/**
 * Implements hook_drush_command().
 */
Pawel G's avatar
Pawel G committed
13
function simple_sitemap_drush_command() {
14
  $items['simple-sitemap-generate'] = [
15
    'description' => 'Regenerate all XML sitemap variants or continue generation.',
Pawel G's avatar
Pawel G committed
16
    'callback' => 'drush_simple_sitemap_generate',
Pawel G's avatar
Pawel G committed
17
    'drupal dependencies' => ['simple_sitemap'],
18
    'aliases' => ['ssg'],
Pawel G's avatar
Pawel G 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
 */
Pawel G's avatar
Pawel G committed
36
function drush_simple_sitemap_generate() {
Pawel G's avatar
Pawel G 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();
}