function LanguageTestController::typeLinkActiveClass
Same name in other branches
- 9 core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::typeLinkActiveClass()
- 10 core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::typeLinkActiveClass()
- 11.x core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::typeLinkActiveClass()
Returns links to the current page with different langcodes.
Using #type 'link' causes these links to be rendered with the link generator.
1 string reference to 'LanguageTestController::typeLinkActiveClass'
- language_test.routing.yml in core/
modules/ language/ tests/ language_test/ language_test.routing.yml - core/modules/language/tests/language_test/language_test.routing.yml
File
-
core/
modules/ language/ tests/ language_test/ src/ Controller/ LanguageTestController.php, line 72
Class
- LanguageTestController
- Controller routines for language_test routes.
Namespace
Drupal\language_test\ControllerCode
public function typeLinkActiveClass() {
// We assume that 'en' and 'fr' have been configured.
$languages = $this->languageManager
->getLanguages();
return [
'no_language' => [
'#type' => 'link',
'#title' => t('Link to the current path with no langcode provided.'),
'#url' => Url::fromRoute('<current>'),
'#options' => [
'attributes' => [
'id' => 'no_lang_link',
],
'set_active_class' => TRUE,
],
],
'fr' => [
'#type' => 'link',
'#title' => t('Link to a French version of the current path.'),
'#url' => Url::fromRoute('<current>'),
'#options' => [
'language' => $languages['fr'],
'attributes' => [
'id' => 'fr_link',
],
'set_active_class' => TRUE,
],
],
'en' => [
'#type' => 'link',
'#title' => t('Link to an English version of the current path.'),
'#url' => Url::fromRoute('<current>'),
'#options' => [
'language' => $languages['en'],
'attributes' => [
'id' => 'en_link',
],
'set_active_class' => TRUE,
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.