Issue #1987644 by mparker17, dawehner: Convert common_test_destination() to a new style controller.
parent
ead42d3822
commit
2dfecb5ed2
|
@ -5,27 +5,6 @@
|
||||||
* Helper module for the Common tests.
|
* 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.
|
* Applies #printed to an element to help test #pre_render.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,6 +4,12 @@ common_test_l_active_class:
|
||||||
_content: '\Drupal\common_test\Controller\CommonTestController::typeLinkActiveClass'
|
_content: '\Drupal\common_test\Controller\CommonTestController::typeLinkActiveClass'
|
||||||
requirements:
|
requirements:
|
||||||
_access: 'TRUE'
|
_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:
|
common_test_drupal_render_invalid_keys:
|
||||||
pattern: 'common-test/drupal-render-invalid-keys'
|
pattern: 'common-test/drupal-render-invalid-keys'
|
||||||
defaults:
|
defaults:
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
|
|
||||||
namespace Drupal\common_test\Controller;
|
namespace Drupal\common_test\Controller;
|
||||||
|
|
||||||
|
use Drupal\Component\Utility\String;
|
||||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller routines for common_test routes.
|
* Controller routines for common_test routes.
|
||||||
|
@ -88,4 +90,18 @@ class CommonTestController implements ContainerInjectionInterface {
|
||||||
return '';
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue