function LanguageNegotiationContentEntity::getLanguageSwitchLinks
Same name in other branches
- 9 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getLanguageSwitchLinks()
- 8.9.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getLanguageSwitchLinks()
- 10 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getLanguageSwitchLinks()
Overrides LanguageSwitcherInterface::getLanguageSwitchLinks
File
-
core/
modules/ language/ src/ Plugin/ LanguageNegotiation/ LanguageNegotiationContentEntity.php, line 145
Class
- LanguageNegotiationContentEntity
- Class for identifying the content translation language.
Namespace
Drupal\language\Plugin\LanguageNegotiationCode
public function getLanguageSwitchLinks(Request $request, $type, Url $url) {
$links = [];
$query = [];
parse_str($request->getQueryString() ?? '', $query);
foreach ($this->languageManager
->getNativeLanguages() as $language) {
$langcode = $language->getId();
$query[static::QUERY_PARAMETER] = $langcode;
$links[$langcode] = [
'url' => $url,
'title' => $language->getName(),
'attributes' => [
'class' => [
'language-link',
],
],
'query' => $query,
];
}
return $links;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.