Commit 51f9ed47 authored by hswong3i's avatar hswong3i Committed by pifagor
Browse files

Issue #2815631 by evaldask, hswong3i, SylvainM, juampynr, alex_optim, pifagor,...

Issue #2815631 by evaldask, hswong3i, SylvainM, juampynr, alex_optim, pifagor, poukram: Incorrect sitemap content urls with languages settings set to domains
parent c6f24511
......@@ -128,7 +128,19 @@ class XmlSitemapWriter extends \XMLWriter {
*/
public function writeXSL() {
// @codingStandardsIgnoreEnd
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . Url::fromRoute('xmlsitemap.sitemap_xsl')->toString() . '"');
$xls_url = Url::fromRoute('xmlsitemap.sitemap_xsl')->toString();
$settings = \Drupal::config('language.negotiation');
if ($settings) {
$url_settings = $settings->get('url');
if (isset($url_settings['source']) && $url_settings['source'] == 'domain') {
$scheme = \Drupal::request()->getScheme();
$context = $this->sitemap->getContext();
$base_url = $scheme . '://' . $url_settings['domains'][$context['language']];
$xls_url = Url::fromRoute('xmlsitemap.sitemap_xsl');
$xls_url = $base_url . "/". $xls_url->getInternalPath();
}
}
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $xls_url . '"');
$this->writeRaw(PHP_EOL);
}
......
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