/**
* {@inheritdoc}
*/
public function getLanguageSwitchLinks($type, Url
$url) { if ($this->negotiator
) { foreach ($this->negotiator->
getNegotiationMethods($type) as $method_id =>
$method) { $reflector =
new \
ReflectionClass($method['class'
]);
if ($reflector->
implementsInterface('\Drupal\language\LanguageSwitcherInterface'
)) { $original_languages =
$this->negotiatedLanguages;
$result =
$this->negotiator->
getNegotiationMethodInstance($method_id)->
getLanguageSwitchLinks($this->requestStack->
getCurrentRequest(),
$type,
$url);
if (!
empty($result)) { // Allow modules to provide translations for specific links.
$this->moduleHandler->
alter('language_switch_links',
$result,
$type,
$url);
$result =
array_filter($result,
function Darray
$link): bool
{ $url =
$link['url'
] ?? NULL;
$language =
$link['language'
] ?? NULL;
if ($language instanceof LanguageInterface
) { $this->negotiatedLanguages
[LanguageInterface::TYPE_CONTENT
] =
$language;
$this->negotiatedLanguages
[LanguageInterface::TYPE_INTERFACE
] =
$language;
}