You are here

protected function LinkGeneratorBase::get_multilang_urls_from_route in Simple XML sitemap 8

Wrapper function for Drupal\Core\Url::fromRoute. Returns url data for every language.

Parameters

$route_name:

$route_parameters:

$options:

Return value

array Returns an array containing the internal path, url objects for every language, url options and access information.

See also

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Url.php/function/...

4 calls to LinkGeneratorBase::get_multilang_urls_from_route()
Menu::get_paths in src/Plugin/LinkGenerator/Menu.php
Returns an array of all urls and their data of a bundle.
NodeType::get_paths in src/Plugin/LinkGenerator/NodeType.php
Returns an array of all urls and their data of a bundle.
TaxonomyVocabulary::get_paths in src/Plugin/LinkGenerator/TaxonomyVocabulary.php
Returns an array of all urls and their data of a bundle.
User::get_paths in src/Plugin/LinkGenerator/User.php
Returns an array of all urls and their data of a bundle.

File

src/LinkGeneratorBase.php, line 152
Contains \Drupal\simplesitemap\LinkGeneratorBase.

Class

LinkGeneratorBase

Namespace

Drupal\simplesitemap

Code

protected function get_multilang_urls_from_route($route_name, $route_parameters = array(), $options = array()) {
  $options['absolute'] = empty($options['absolute']) ? TRUE : $options['absolute'];
  $url_object = Url::fromRoute($route_name, $route_parameters, $options);
  $urls = array();
  foreach ($this->languages as $language) {
    if ($language
      ->getId() === $this->default_language_id) {
      $urls[$this->default_language_id] = $url_object
        ->toString();
    }
    else {
      $options['language'] = $language;
      $urls[$language
        ->getId()] = Url::fromRoute($route_name, $route_parameters, $options)
        ->toString();
    }
  }
  return array(
    'path' => $url_object
      ->getInternalPath(),
    'urls' => $urls,
    'options' => $url_object
      ->getOptions(),
    'access' => $this
      ->access($url_object),
  );
}