Skip to content
Snippets Groups Projects
Commit f2c5683d authored by Al Munnings's avatar Al Munnings Committed by Al Munnings
Browse files

Issue #3390590 by almunnings, Yury N, CedricL: MenuItem route should not inherit language from menu

parent e8167e25
No related branches found
No related tags found
1 merge request!54Issue #3390590 by almunnings, Yury N, CedricL: MenuItem route should not inherit language from menu
Pipeline #71370 canceled
...@@ -68,7 +68,7 @@ class ContextLanguage extends DataProducerPluginBase implements ContainerFactory ...@@ -68,7 +68,7 @@ class ContextLanguage extends DataProducerPluginBase implements ContainerFactory
* *
* It can do weird things if changing language mid-query. * It can do weird things if changing language mid-query.
* *
* @param string|null $language * @param string|null $langcode
* The language to resolve the url in. * The language to resolve the url in.
* @param \Drupal\graphql\GraphQL\Execution\FieldContext $context * @param \Drupal\graphql\GraphQL\Execution\FieldContext $context
* The cache context. * The cache context.
...@@ -76,14 +76,20 @@ class ContextLanguage extends DataProducerPluginBase implements ContainerFactory ...@@ -76,14 +76,20 @@ class ContextLanguage extends DataProducerPluginBase implements ContainerFactory
* @return string|null * @return string|null
* The language in use. * The language in use.
*/ */
public function resolve(?string $language, FieldContext $context): ?string { public function resolve(?string $langcode, FieldContext $context): ?string {
if ($langcode && $this->languageManager->isMultilingual()) {
$language = $this->languageManager->getLanguage($langcode);
if ($language) {
$context->setContextLanguage($langcode);
$this->languageManager->setConfigOverrideLanguage($language);
}
if ($language && $this->languageManager->isMultilingual()) {
$context->setContextLanguage($language);
$this->languageManager->reset(); $this->languageManager->reset();
} }
return $language; return $langcode;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment