protected function LinkGeneratorBase::get_multilang_urls_from_user_input in Simple XML sitemap 8
Wrapper function for Drupal\Core\Url::fromUserInput. Returns url data for every language.
Parameters
$user_input:
$options:
Return value
array or FALSE Returns an array containing the internal path, url objects for every language, url options and access information. Returns FALSE if path does not exist.
See also
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Url.php/function/...
2 calls to LinkGeneratorBase::get_multilang_urls_from_user_input()
- CustomLinkGenerator::get_paths in src/
CustomLinkGenerator.php - Returns an array of all urls of the custom paths.
- LinkGeneratorBase::get_entity_paths in src/
LinkGeneratorBase.php
File
- src/
LinkGeneratorBase.php, line 186 - Contains \Drupal\simplesitemap\LinkGeneratorBase.
Class
Namespace
Drupal\simplesitemapCode
protected function get_multilang_urls_from_user_input($user_input, $options = array()) {
$user_input = $user_input[0] === '/' ? $user_input : '/' . $user_input;
if (!\Drupal::service('path.validator')
->isValid($user_input)) {
$this
->register_error(self::PATH_DOES_NOT_EXIST, array(
'@faulty_path' => $user_input,
), 'warning');
return FALSE;
}
$options['absolute'] = empty($options['absolute']) ? TRUE : $options['absolute'];
$url_object = Url::fromUserInput($user_input, $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::fromUserInput($user_input, $options)
->toString();
}
}
return array(
'path' => $url_object
->getInternalPath(),
'urls' => $urls,
'options' => $url_object
->getOptions(),
'access' => $this
->access($url_object),
);
}