diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index 0ffb8dae611f28963f12239cf829788e0bc53ed9..cb97937ebb2bbcfed99a8f15f2a0170c051c51a3 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -109,16 +109,6 @@ function language_test_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); - $items['language_test/l-active-class'] = array( - 'page callback' => 'language_test_l_active_class', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); - $items['language_test/theme-link-active-class'] = array( - 'page callback' => 'language_test_theme_link_active_class', - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - ); return $items; } @@ -129,89 +119,3 @@ function language_test_menu() { function language_test_subrequest() { return drupal_container()->get('http_kernel')->handle(Request::create('/user'), HttpKernelInterface::SUB_REQUEST); } - -/** - * Page callback: Displays links to the current page, with different langcodes. - * - * Using #theme causes these links to be rendered with theme_link(). - */ -function language_test_theme_link_active_class() { - $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', - ), - ), - ), - ); -} - -/** - * Page callback: Displays links to the current page, with different langcodes. - * - * Using #type causes these links to be rendered with l(). - */ -function language_test_l_active_class() { - $languages = language_list(); - return array( - 'no_language' => array( - '#type' => 'link', - '#title' => t('Link to the current path with no langcode provided.'), - '#href' => current_path(), - '#options' => array( - 'attributes' => array( - 'id' => 'no_lang_link', - ), - ), - ), - 'fr' => array( - '#type' => 'link', - '#title' => t('Link to a French version of the current path.'), - '#href' => current_path(), - '#options' => array( - 'language' => $languages['fr'], - 'attributes' => array( - 'id' => 'fr_link', - ), - ), - ), - 'en' => array( - '#type' => 'link', - '#title' => t('Link to an English version of the current path.'), - '#href' => current_path(), - '#options' => array( - 'language' => $languages['en'], - 'attributes' => array( - 'id' => 'en_link', - ), - ), - ), - ); -} diff --git a/core/modules/language/tests/language_test/language_test.routing.yml b/core/modules/language/tests/language_test/language_test.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..bd560319b0f5a5cde0191378e88085e6918b81e8 --- /dev/null +++ b/core/modules/language/tests/language_test/language_test.routing.yml @@ -0,0 +1,13 @@ +language_test_l_active_class: + pattern: '/language_test/l-active-class' + defaults: + _content: '\Drupal\language_test\Controller\LanguageTestController::lActiveClass' + requirements: + _permission: 'true' + +language_test_theme_link_active_class: + pattern: '/language_test/theme-link-active-class' + defaults: + _content: '\Drupal\language_test\Controller\LanguageTestController::themeLinkActiveClass' + requirements: + _permission: 'true' diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php new file mode 100644 index 0000000000000000000000000000000000000000..876699babe4285fa445081dc70f9b03d9f5f84a9 --- /dev/null +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/Controller/LanguageTestController.php @@ -0,0 +1,112 @@ + 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', + ), + ), + ), + ); + } + + /** + * Returns links to the current page with different langcodes. + * + * Using #type causes these links to be rendered with l(). + */ + public function lActiveClass() { + // We assume that 'en' and 'fr' have been configured. + $languages = language_list(); + return array( + 'no_language' => array( + '#type' => 'link', + '#title' => t('Link to the current path with no langcode provided.'), + '#href' => current_path(), + '#options' => array( + 'attributes' => array( + 'id' => 'no_lang_link', + ), + ), + ), + 'fr' => array( + '#type' => 'link', + '#title' => t('Link to a French version of the current path.'), + '#href' => current_path(), + '#options' => array( + 'language' => $languages['fr'], + 'attributes' => array( + 'id' => 'fr_link', + ), + ), + ), + 'en' => array( + '#type' => 'link', + '#title' => t('Link to an English version of the current path.'), + '#href' => current_path(), + '#options' => array( + 'language' => $languages['en'], + 'attributes' => array( + 'id' => 'en_link', + ), + ), + ), + ); + } + +}