diff --git a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php index c790a84..914809b 100644 --- a/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php +++ b/core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php @@ -31,4 +31,17 @@ function functionTemplateOverridden() { ); } + + /** + * Calls drupal_alter(). + * + * This is for testing that the theme can have hook_*_alter() implementations + * that run during page callback execution, even before theme() is called for + * the first time. + */ + function themeTestAlter() { + $data = 'foo'; + drupal_alter('theme_test_alter', $data); + return "The altered data is $data."; + } } diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 40a78f3..6ab8f04 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -54,8 +54,7 @@ function theme_test_menu() { ); $items['theme-test/alter'] = array( 'title' => 'Suggestion', - 'page callback' => '_theme_test_alter', - 'access callback' => TRUE, + 'route_name' => 'theme_test_alter', 'theme callback' => '_theme_custom_theme', 'type' => MENU_CALLBACK, ); @@ -130,19 +129,6 @@ function _theme_custom_theme() { } /** - * Page callback, calls drupal_alter(). - * - * This is for testing that the theme can have hook_*_alter() implementations - * that run during page callback execution, even before theme() is called for - * the first time. - */ -function _theme_test_alter() { - $data = 'foo'; - drupal_alter('theme_test_alter', $data); - return "The altered data is $data."; -} - -/** * Page callback, calls a theme hook suggestion. */ function _theme_test_suggestion() { diff --git a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml index 866171e..6fd74ae 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.routing.yml +++ b/core/modules/system/tests/modules/theme_test/theme_test.routing.yml @@ -4,3 +4,10 @@ function_template_override: _content: '\Drupal\theme_test\ThemeTestController::functionTemplateOverridden' requirements: _permission: 'access content' + +theme_test_alter: + pattern: 'theme-test/alter' + defaults: + _content: '\Drupal\theme_test\ThemeTestController::themeTestAlter' + requirements: + _access: 'TRUE'