3 namespace Drupal\menu_test;
5 use Drupal\Component\Utility\SafeMarkup;
8 * Controllers for testing the menu integration routing system.
10 class TestControllers {
13 * Returns page to be used as a login path.
15 public function testLogin() {
16 return ['#markup' => 'This is TestControllers::testLogin.'];
20 * Prints out test data.
22 public function test1() {
23 return ['#markup' => 'test1'];
27 * Prints out test data.
29 public function test2() {
30 return ['#markup' => 'test2'];
34 * Prints out test data.
36 public function testSession() {
37 if (!isset($_SESSION['menu_test'])) {
38 $_SESSION['menu_test'] = 0;
40 $_SESSION['menu_test']++;
41 return ['#markup' => SafeMarkup::format('Session menu_test is @count', ['@count' => $_SESSION['menu_test']])];
45 * Prints out test data.
47 public function testDerived() {
48 return ['#markup' => 'testDerived'];
52 * Prints out test data.
54 * @param string|null $placeholder
55 * A placeholder for the return string.
58 * The string for this route.
60 public function testDefaults($placeholder = NULL) {
62 return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", ['@placeholder' => $placeholder])];
65 return ['#markup' => 'Sometimes there is no placeholder.'];
70 * Prints out test data with contextual links.
72 public function testContextual() {
74 '#markup' => 'testContextual',
76 '#type' => 'contextual_links',
77 '#contextual_links' => [
79 'route_parameters' => ['bar' => 1],