SimplesitemapCommands.php 1.35 KB
Newer Older
1 2 3 4 5 6 7 8
<?php

namespace Drupal\simple_sitemap\Commands;

use Drupal\simple_sitemap\Simplesitemap;
use Drush\Commands\DrushCommands;

/**
gbyte.co's avatar
gbyte.co committed
9
 * Class SimplesitemapCommands
10 11
 * @package Drupal\simple_sitemap\Commands
 */
gbyte.co's avatar
gbyte.co committed
12
class SimplesitemapCommands extends DrushCommands {
13 14 15 16 17 18 19

  /**
   * @var \Drupal\simple_sitemap\Simplesitemap
   */
  protected $generator;

  /**
gbyte.co's avatar
gbyte.co committed
20
   * SimplesitemapCommands constructor.
21 22 23 24 25 26 27
   * @param \Drupal\simple_sitemap\Simplesitemap $generator
   */
  public function __construct(Simplesitemap $generator) {
    $this->generator = $generator;
  }

  /**
28
   * Regenerate the XML sitemaps according to the module settings.
29 30
   *
   * @command simple-sitemap:generate
31 32 33 34
   *
   * @usage drush simple-sitemap:generate
   *   Regenerate the XML sitemaps according to the module settings.
   *
35
   * @validate-module-enabled simple_sitemap
36 37
   *
   * @aliases ssg, simple-sitemap-generate
38 39
   */
  public function generate() {
gbyte.co's avatar
gbyte.co committed
40
    $this->generator->generateSitemap('drush');
41 42
  }

43 44 45 46
  /**
   * Rebuild the sitemap queue for all sitemap variants.
   *
   * @command simple-sitemap:rebuild-queue
47 48 49 50
   *
   * @usage drush simple-sitemap:rebuild-queue
   *   Rebuild the sitemap queue for all sitemap variants.
   *
51
   * @validate-module-enabled simple_sitemap
52 53
   *
   * @aliases ssr, simple-sitemap-rebuild-queue
54 55 56 57 58
   */
  public function rebuildQueue() {
    $this->generator->rebuildQueue();
  }

59
}