diff --git a/core/modules/language/language.services.yml b/core/modules/language/language.services.yml index d7d8c37..c102e17 100644 --- a/core/modules/language/language.services.yml +++ b/core/modules/language/language.services.yml @@ -12,7 +12,7 @@ services: arguments: ['@language_manager', '@language_negotiator', '@string_translation', '@current_user'] path_processor_language: class: Drupal\language\HttpKernel\PathProcessorLanguage - arguments: ['@config.factory', '@settings', '@language_manager', '@language_negotiator'] + arguments: ['@config.factory', '@settings', '@language_manager', '@language_negotiator', '@current_user'] tags: - { name: path_processor_inbound, priority: 300 } - { name: path_processor_outbound, priority: 100 } diff --git a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php index 4d57731..24428f2 100644 --- a/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php +++ b/core/modules/language/lib/Drupal/language/HttpKernel/PathProcessorLanguage.php @@ -15,6 +15,7 @@ use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\language\LanguageNegotiatorInterface; use Symfony\Component\HttpFoundation\Request; +use Drupal\Core\Session\AccountInterface; /** * Processes the inbound path using path alias lookups. @@ -50,6 +51,13 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa protected $negotiator; /** + * The current active user. + * + * @return \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + + /** * Local cache for language path processors. * * @var array @@ -72,12 +80,17 @@ class PathProcessorLanguage implements InboundPathProcessorInterface, OutboundPa * The settings instance. * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager * The configurable language manager. + * @param \Drupal\language\LanguageNegotiatorInterface + * The language negotiator. + * @param \Drupal\Core\Session\AccountInterface $current_user + * The current active user. */ - public function __construct(ConfigFactory $config, Settings $settings, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator) { + public function __construct(ConfigFactory $config, Settings $settings, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator, AccountInterface $current_user) { $this->config = $config; $this->mixedModeSessions = $settings->get('mixed_mode_sessions', FALSE); $this->languageManager = $language_manager; $this->negotiator = $negotiator; + $this->currentUser = $current_user; } /** @@ -104,6 +117,7 @@ public function processOutbound($path, &$options = array(), Request $request = N $this->multilingual = $this->languageManager->isMultilingual(); } if ($this->multilingual) { + $this->negotiator->setContext($this->currentUser, $request); $scope = 'outbound'; if (!isset($this->processors[$scope])) { $this->initProcessors($scope);