Commit 60b09f4d authored by gbyte.co's avatar gbyte.co Committed by gbyte.co

Issue #2996734 by gbyte.co, mitrpaka, kirkkala: Page not found opens instead...

Issue #2996734 by gbyte.co, mitrpaka, kirkkala: Page not found opens instead correct sitemap.xml when path prefix for URL language detection enabled
parent 5299978e
......@@ -234,10 +234,3 @@ function simple_sitemap_menu_delete(MenuInterface $menu) {
$generator = \Drupal::service('simple_sitemap.generator');
$generator->setVariants(TRUE)->removeBundleSettings('menu_link_content', $menu->id());
}
/**
* Implements hook_language_negotiation_info_alter().
*/
function simple_sitemap_language_negotiation_info_alter(&$negotiation_info) {
$negotiation_info['language-url']['class'] = 'Drupal\simple_sitemap\Plugin\LanguageNegotiation\SimplesitemapLanguageNegotiationUrl';
}
......@@ -2,6 +2,7 @@ simple_sitemap.sitemap_default:
path: '/sitemap.xml'
defaults:
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemap'
_disable_route_normalizer: 'TRUE'
requirements:
_access: 'TRUE'
......@@ -13,6 +14,7 @@ simple_sitemap.sitemap_variant:
path: '/sitemaps/{variant}/sitemap.xml'
defaults:
_controller: '\Drupal\simple_sitemap\Controller\SimplesitemapController::getSitemap'
_disable_route_normalizer: 'TRUE'
requirements:
_access: 'TRUE'
......
......@@ -76,7 +76,7 @@ services:
- '@messenger'
- '@current_user'
simple_sitemap.variant:
simple_sitemap.path_processor_variant:
class: Drupal\simple_sitemap\PathProcessor\PathProcessorSitemapVariant
tags:
- { name: path_processor_inbound, priority: 300 }
......
<?php
namespace Drupal\simple_sitemap\Plugin\LanguageNegotiation;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Symfony\Component\HttpFoundation\Request;
/**
* {@inheritdoc}
*/
class SimplesitemapLanguageNegotiationUrl extends LanguageNegotiationUrl {
/**
* {@inheritdoc}
*/
public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$config = $this->config->get('language.negotiation')->get('url');
if ($config['source'] === LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
$args = explode('/', $path);
if (count($args) === 4 && $args[1] === 'sitemaps' && $args[3] === 'sitemap.xml') {
return $path;
}
}
return parent::processOutbound($path, $options, $request, $bubbleable_metadata);
}
}
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