public function LanguageTestController::themeLinkActiveClass

Returns links to the current page with different langcodes.

Using #theme causes these links to be rendered with theme_link().

1 string reference to 'LanguageTestController::themeLinkActiveClass'
language_test.routing.yml in drupal/core/modules/language/tests/language_test/language_test.routing.yml
drupal/core/modules/language/tests/language_test/language_test.routing.yml

File

drupal/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php, line 30
Contains \Drupal\language_test\Controller\LanguageTestController.

Class

LanguageTestController
Controller routines for language_test routes.

Namespace

Drupal\language_test\Controller

Code

public function themeLinkActiveClass() {

  // We assume that 'en' and 'fr' have been configured.
  $languages = language_list();
  return array(
    'no_language' => array(
      '#theme' => 'link',
      '#text' => t('Link to the current path with no langcode provided.'),
      '#path' => current_path(),
      '#options' => array(
        'attributes' => array(
          'id' => 'no_lang_link',
        ),
      ),
    ),
    'fr' => array(
      '#theme' => 'link',
      '#text' => t('Link to a French version of the current path.'),
      '#path' => current_path(),
      '#options' => array(
        'language' => $languages['fr'],
        'attributes' => array(
          'id' => 'fr_link',
        ),
      ),
    ),
    'en' => array(
      '#theme' => 'link',
      '#text' => t('Link to an English version of the current path.'),
      '#path' => current_path(),
      '#options' => array(
        'language' => $languages['en'],
        'attributes' => array(
          'id' => 'en_link',
        ),
      ),
    ),
  );
}