Skip to content
Snippets Groups Projects
Commit f4a54b14 authored by Andrey Tymchuk's avatar Andrey Tymchuk Committed by A.Tymchuk
Browse files

Issue #3340003 by duaelfr, jwilson3, gbyte, walkingdexter: Accessibility:...

Issue #3340003 by duaelfr, jwilson3, gbyte, walkingdexter: Accessibility: "Language is missing or invalid" in sitemap.xml XSL transform
parent c499cf45
No related branches found
No related tags found
No related merge requests found
Pipeline #282490 passed
......@@ -154,6 +154,7 @@ class DefaultSitemapGenerator extends SitemapGeneratorBase {
$module_path = $this->moduleList->getPath('simple_sitemap');
$xsl_content = file_get_contents($module_path . '/xsl/simple_sitemap.xsl');
$replacements = [
'[langcode]' => $this->languageManager->getCurrentLanguage()->getId(),
'[title]' => $this->t('Sitemap file'),
'[generated-by]' => $this->settings->get('hide_branding')
? ''
......
......@@ -4,6 +4,7 @@ namespace Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGenerator;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\simple_sitemap\Entity\SimpleSitemapInterface;
use Drupal\simple_sitemap\Plugin\simple_sitemap\SimpleSitemapPluginBase;
use Drupal\simple_sitemap\Settings;
......@@ -51,6 +52,13 @@ abstract class SitemapGeneratorBase extends SimpleSitemapPluginBase implements S
*/
protected $moduleList;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* An array of index attributes.
*
......@@ -77,6 +85,8 @@ abstract class SitemapGeneratorBase extends SimpleSitemapPluginBase implements S
* The simple_sitemap.settings service.
* @param \Drupal\Core\Extension\ModuleExtensionList $module_list
* The extension.list.module service.
* @param \Drupal\Core\Language\LanguageManagerInterface|null $language_manager
* The language manager.
*/
public function __construct(
array $configuration,
......@@ -86,12 +96,19 @@ abstract class SitemapGeneratorBase extends SimpleSitemapPluginBase implements S
SitemapWriter $sitemap_writer,
Settings $settings,
ModuleExtensionList $module_list,
?LanguageManagerInterface $language_manager = NULL,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->moduleHandler = $module_handler;
$this->writer = $sitemap_writer;
$this->settings = $settings;
$this->moduleList = $module_list;
if ($language_manager === NULL) {
@trigger_error('Calling ' . __METHOD__ . ' without the $language_manager argument is deprecated in simple_sitemap:4.2.2 and will be required in simple_sitemap:5.0.0. See https://www.drupal.org/project/simple_sitemap/issues/3340003', E_USER_DEPRECATED);
// @phpstan-ignore-next-line
$language_manager = \Drupal::languageManager();
}
$this->languageManager = $language_manager;
}
/**
......@@ -105,7 +122,8 @@ abstract class SitemapGeneratorBase extends SimpleSitemapPluginBase implements S
$container->get('module_handler'),
$container->get('simple_sitemap.sitemap_writer'),
$container->get('simple_sitemap.settings'),
$container->get('extension.list.module')
$container->get('extension.list.module'),
$container->get('language_manager')
);
}
......
......@@ -8,7 +8,7 @@
<!-- Root template -->
<xsl:template match="/">
<html>
<html lang="[langcode]">
<head>
<title>[title]</title>
<script type="text/javascript" src="[jquery]"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment