Commit 87922e89 authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #2935372 by herve: base:/ menu items are not added to sitemap

parent ac905945
......@@ -104,9 +104,9 @@ class EntityHelper {
* @return object|null
*/
public function getEntityFromUrlObject(Url $url_object) {
$route_parameters = $url_object->getRouteParameters();
return !empty($route_parameters) && $this->entityTypeManager
->getDefinition($entity_type_id = key($route_parameters), FALSE)
return $url_object->isRouted()
&& !empty($route_parameters = $url_object->getRouteParameters())
&& $this->entityTypeManager->getDefinition($entity_type_id = key($route_parameters), FALSE)
? $this->entityTypeManager->getStorage($entity_type_id)
->load($route_parameters[$entity_type_id])
: NULL;
......
......@@ -121,7 +121,7 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
$url_object = $link->getUrlObject();
// Do not include external paths.
if (!$url_object->isRouted()) {
if ($url_object->isExternal()) {
return FALSE;
}
......@@ -140,7 +140,18 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
}
}
$path = $url_object->getInternalPath();
// There can be internal paths that are not rooted, like 'base:/path'.
if ($url_object->isRouted()) {
$path = $url_object->getInternalPath();
}
else { // Handle base scheme.
if (strpos($uri = $url_object->toUriString(), 'base:/') === 0 ) {
$path = $uri[6] === '/' ? substr($uri, 7) : substr($uri, 6);
}
else { // Handle unforeseen schemes.
$path = $uri;
}
}
// Do not include paths that have been already indexed.
if ($this->batchSettings['remove_duplicates'] && $this->pathProcessed($path)) {
......
......@@ -223,9 +223,13 @@ abstract class UrlGeneratorBase extends UrlGeneratorPluginBase implements UrlGen
* @param array $path_data
*/
protected function addUrlVariants(array $path_data, Url $url_object) {
$entity = $this->entityHelper->getEntityFromUrlObject($url_object);
if ($entity instanceof ContentEntityBase && $this->batchSettings['skip_untranslated']) {
if (!$url_object->isRouted()) {
// Not a routed URL, including only default variant.
$alternate_urls = $this->getAlternateUrlsForDefaultLanguage($url_object);
}
elseif ($this->batchSettings['skip_untranslated']
&& ($entity = $this->entityHelper->getEntityFromUrlObject($url_object)) instanceof ContentEntityBase) {
$translation_languages = $entity->getTranslationLanguages();
if (isset($translation_languages[Language::LANGCODE_NOT_SPECIFIED])
|| isset($translation_languages[Language::LANGCODE_NOT_APPLICABLE])) {
......
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