You are here

protected function EntityUrlGeneratorBase::getAlternateUrlsForTranslatedLanguages in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGeneratorBase::getAlternateUrlsForTranslatedLanguages()

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity:

\Drupal\Core\Url $url_object:

Return value

array

1 call to EntityUrlGeneratorBase::getAlternateUrlsForTranslatedLanguages()
EntityUrlGeneratorBase::getUrlVariants in src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php

File

src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php, line 158

Class

EntityUrlGeneratorBase
Class EntityUrlGeneratorBase

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function getAlternateUrlsForTranslatedLanguages(ContentEntityInterface $entity, Url $url_object) : array {
  $alternate_urls = [];

  /** @var Language $language */
  foreach ($entity
    ->getTranslationLanguages() as $language) {
    if (!isset($this->settings
      ->get('excluded_languages')[$language
      ->getId()]) || $language
      ->isDefault()) {
      if ($entity
        ->getTranslation($language
        ->getId())
        ->access('view', $this->anonUser)) {
        $alternate_urls[$language
          ->getId()] = $this
          ->replaceBaseUrlWithCustom($url_object
          ->setAbsolute()
          ->setOption('language', $language)
          ->toString());
      }
    }
  }
  return $alternate_urls;
}