You are here

public function Simplesitemap::generateSitemap in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 8.2 src/Simplesitemap.php \Drupal\simple_sitemap\Simplesitemap::generateSitemap()

Generates all sitemaps.

Parameters

string $from: Can be 'form', 'drush', 'cron' and 'backend'.

Return value

$this

Throws

\Drupal\Component\Plugin\Exception\PluginException

File

src/Simplesitemap.php, line 342

Class

Simplesitemap
Class Simplesitemap @package Drupal\simple_sitemap

Namespace

Drupal\simple_sitemap

Code

public function generateSitemap($from = QueueWorker::GENERATE_TYPE_FORM) {
  if (!$this->lock
    ->lockMayBeAvailable(QueueWorker::LOCK_ID)) {
    $this->logger
      ->m('Unable to acquire a lock for sitemap generation.')
      ->log('error')
      ->display('error');
    return $this;
  }
  switch ($from) {
    case QueueWorker::GENERATE_TYPE_FORM:
    case QueueWorker::GENERATE_TYPE_DRUSH:
      $this->queueWorker
        ->batchGenerateSitemap($from);
      break;
    case QueueWorker::GENERATE_TYPE_CRON:
    case QueueWorker::GENERATE_TYPE_BACKEND:
      $this->queueWorker
        ->generateSitemap($from);
      break;
  }
  return $this;
}