diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index dd1687d56bac738588fe656c5e54a3a8a5d5f19d..915dac19f6bec95650f357127700a4a7739319eb 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -215,7 +215,7 @@ public function getFallbackCandidates(array $context = []) { * {@inheritdoc} */ public function getLanguageSwitchLinks($type, Url $url) { - return []; + return NULL; } /** diff --git a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php index 9a6b213d645ef0302355690274ad221923245d0d..7f7306d421021c9503b402259766d676e8005646 100644 --- a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php @@ -171,8 +171,11 @@ public function getFallbackCandidates(array $context = []); * @param \Drupal\Core\Url $url * The URL the switch links will be relative to. * - * @return array - * A keyed array of links ready to be themed. + * @return object|null + * An object with the following keys: + * - links: An array of links indexed by the language ID + * - method_id: The language negotiation method ID + * or NULL if there are no language switch links. */ public function getLanguageSwitchLinks($type, Url $url); diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php index 143adf604b3344be22e8b9f972d96e9fcb5ae679..9dd65ff4953a215e018834b8033fef1416e92306 100644 --- a/core/modules/language/src/ConfigurableLanguageManager.php +++ b/core/modules/language/src/ConfigurableLanguageManager.php @@ -403,8 +403,6 @@ public function getFallbackCandidates(array $context = []) { * {@inheritdoc} */ public function getLanguageSwitchLinks($type, Url $url) { - $links = FALSE; - if ($this->negotiator) { foreach ($this->negotiator->getNegotiationMethods($type) as $method_id => $method) { $reflector = new \ReflectionClass($method['class']); @@ -422,7 +420,7 @@ public function getLanguageSwitchLinks($type, Url $url) { } } - return $links; + return $links ?? NULL; } /**