SimplesitemapCommands.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Drupal\simple_sitemap\Commands;
  3. use Drupal\simple_sitemap\Simplesitemap;
  4. use Drush\Commands\DrushCommands;
  5. /**
  6. * Class SimplesitemapCommands
  7. * @package Drupal\simple_sitemap\Commands
  8. */
  9. class SimplesitemapCommands extends DrushCommands {
  10. /**
  11. * @var \Drupal\simple_sitemap\Simplesitemap
  12. */
  13. protected $generator;
  14. /**
  15. * SimplesitemapCommands constructor.
  16. * @param \Drupal\simple_sitemap\Simplesitemap $generator
  17. */
  18. public function __construct(Simplesitemap $generator) {
  19. $this->generator = $generator;
  20. }
  21. /**
  22. * Regenerate the XML sitemaps according to the module settings.
  23. *
  24. * @command simple-sitemap:generate
  25. *
  26. * @usage drush simple-sitemap:generate
  27. * Regenerate the XML sitemaps according to the module settings.
  28. *
  29. * @validate-module-enabled simple_sitemap
  30. *
  31. * @aliases ssg, simple-sitemap-generate
  32. */
  33. public function generate() {
  34. $this->generator->generateSitemap('drush');
  35. }
  36. /**
  37. * Rebuild the sitemap queue for all sitemap variants.
  38. *
  39. * @command simple-sitemap:rebuild-queue
  40. *
  41. * @usage drush simple-sitemap:rebuild-queue
  42. * Rebuild the sitemap queue for all sitemap variants.
  43. *
  44. * @validate-module-enabled simple_sitemap
  45. *
  46. * @aliases ssr, simple-sitemap-rebuild-queue
  47. */
  48. public function rebuildQueue() {
  49. $this->generator->rebuildQueue();
  50. }
  51. }