Commit 4e9cf0be authored by gbyte.co's avatar gbyte.co

Clean up

parent 03761aae
......@@ -18,7 +18,7 @@ services:
simple_sitemap.manager:
class: Drupal\simple_sitemap\SimplesitemapManager
public: true
public: false
arguments:
- '@config.factory'
- '@plugin.manager.simple_sitemap.sitemap_type'
......@@ -28,7 +28,7 @@ services:
simple_sitemap.settings:
class: Drupal\simple_sitemap\SimplesitemapSettings
public: true
public: false
arguments:
- '@config.factory'
......
......@@ -178,22 +178,23 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
protected function getAlternateUrlsForDefaultLanguage(Url $url_object) {
$alternate_urls = [];
if ($url_object->access($this->anonUser)) {
$url_object->setOption('language', $this->languages[$this->defaultLanguageId]);
$alternate_urls[$this->defaultLanguageId] = $this->replaceBaseUrlWithCustom($url_object->toString());
$alternate_urls[$this->defaultLanguageId] = $this->replaceBaseUrlWithCustom($url_object
->setOption('language', $this->languages[$this->defaultLanguageId])->toString()
);
}
return $alternate_urls;
}
protected function getAlternateUrlsForTranslatedLanguages(ContentEntityBase $entity, Url $url_object) {
$alternate_urls = [];
foreach ($entity->getTranslationLanguages() as $language) {
/** @var Language $language */
/** @var Language $language */
foreach ($entity->getTranslationLanguages() as $language) {
if (!isset($this->settings['excluded_languages'][$language->getId()]) || $language->isDefault()) {
$translation = $entity->getTranslation($language->getId());
if ($translation->access('view', $this->anonUser)) {
$url_object->setOption('language', $language);
$alternate_urls[$language->getId()] = $this->replaceBaseUrlWithCustom($url_object->toString());
if ($entity->getTranslation($language->getId())->access('view', $this->anonUser)) {
$alternate_urls[$language->getId()] = $this->replaceBaseUrlWithCustom($url_object
->setOption('language', $language)->toString()
);
}
}
}
......@@ -205,8 +206,9 @@ abstract class UrlGeneratorBase extends SimplesitemapPluginBase implements UrlGe
if ($url_object->access($this->anonUser)) {
foreach ($this->languages as $language) {
if (!isset($this->settings['excluded_languages'][$language->getId()]) || $language->isDefault()) {
$url_object->setOption('language', $language);
$alternate_urls[$language->getId()] = $this->replaceBaseUrlWithCustom($url_object->toString());
$alternate_urls[$language->getId()] = $this->replaceBaseUrlWithCustom($url_object
->setOption('language', $language)->toString()
);
}
}
}
......
......@@ -188,13 +188,13 @@ class QueueWorker {
}
/**
* @param null $variants
* @param string $from
* @return $this
* @throws \Drupal\Component\Plugin\Exception\PluginException
*
* @todo Lock functionality
*/
public function generateSitemap($variants = NULL) {
public function generateSitemap($from = 'form') {
$this->generatorSettings = [
'base_url' => $this->settings->getSetting('base_url', ''),
......@@ -210,7 +210,7 @@ class QueueWorker {
$this->unstashResults();
if (!$this->generationInProgress()) {
$this->rebuildQueue($variants);
$this->rebuildQueue();
}
while ($element = $this->queue->claimItem()) {
......
......@@ -234,9 +234,9 @@ class Simplesitemap {
* @param int $delta
*
* @return string|false
* If no sitemap ID provided, either a sitemap index is returned, or the
* If no sitemap delta is provided, either a sitemap index is returned, or the
* whole sitemap variant, if the amount of links does not exceed the max
* links setting. If a sitemap ID is provided, a sitemap chunk is returned.
* links setting. If a sitemap delta is provided, a sitemap chunk is returned.
* Returns false if the sitemap is not retrievable from the database.
*/
public function getSitemap($delta = NULL) {
......@@ -334,12 +334,12 @@ class Simplesitemap {
switch($from) {
case 'form':
case 'drush':
$this->queueWorker->batchGenerateSitemap($from, $this->getVariants());
$this->queueWorker->batchGenerateSitemap($from);
break;
case 'cron':
case 'backend':
$this->queueWorker->generateSitemap($this->getVariants());
$this->queueWorker->generateSitemap($from);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment