diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index aed0bc6..af93332 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -6,27 +6,6 @@ */ /** - * Implements hook_menu(). - */ -function common_test_menu() { - $items['common-test/destination'] = array( - 'title' => 'Drupal Get Destination', - 'page callback' => 'common_test_destination', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * Prints a destination query parameter. - */ -function common_test_destination() { - $destination = drupal_get_destination(); - print "The destination: " . check_plain($destination['destination']); -} - -/** * Applies #printed to an element to help test #pre_render. */ function common_test_drupal_render_printing_pre_render($elements) { diff --git a/core/modules/system/tests/modules/common_test/common_test.routing.yml b/core/modules/system/tests/modules/common_test/common_test.routing.yml index dc61d7a..6c7d6d3 100644 --- a/core/modules/system/tests/modules/common_test/common_test.routing.yml +++ b/core/modules/system/tests/modules/common_test/common_test.routing.yml @@ -4,6 +4,12 @@ common_test_l_active_class: _content: '\Drupal\common_test\Controller\CommonTestController::typeLinkActiveClass' requirements: _access: 'TRUE' +common_test_destination: + pattern: '/common-test/destination' + defaults: + _controller: '\Drupal\common_test\Controller\CommonTestController::destination' + requirements: + _permission: 'access content' common_test_drupal_render_invalid_keys: pattern: 'common-test/drupal-render-invalid-keys' defaults: diff --git a/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php b/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php index 4e76035..d842919 100644 --- a/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php +++ b/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php @@ -7,8 +7,10 @@ namespace Drupal\common_test\Controller; +use Drupal\Component\Utility\String; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Response; /** * Controller routines for common_test routes. @@ -88,4 +90,18 @@ public function jsAndCssQuerystring() { return ''; } + /** + * Prints a destination query parameter. + * + * @return \Symfony\Component\HttpFoundation\Response + * A new Response object containing a string with the destination query + * parameter. + */ + public function destination() { + $destination = drupal_get_destination(); + $output = "The destination: " . String::checkPlain($destination['destination']); + + return new Response($output); + } + }