From 2dfecb5ed2fd2bde874cfcea03908663c269b9ad Mon Sep 17 00:00:00 2001 From: webchick Date: Sat, 14 Sep 2013 23:35:51 -0700 Subject: [PATCH] Issue #1987644 by mparker17, dawehner: Convert common_test_destination() to a new style controller. --- .../modules/common_test/common_test.module | 21 ------------------- .../common_test/common_test.routing.yml | 6 ++++++ .../Controller/CommonTestController.php | 16 ++++++++++++++ 3 files changed, 22 insertions(+), 21 deletions(-) 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 aed0bc6f16f8..af933327d3f6 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -5,27 +5,6 @@ * Helper module for the Common tests. */ -/** - * 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. */ 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 dc61d7af1ee5..6c7d6d346910 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 4e76035503bd..d8429192934a 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 @@ class CommonTestController implements ContainerInjectionInterface { 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); + } + }