dafaab0e511cceb11cac02c34da85d37cea5a134
[yaffs-website] / web / core / modules / system / tests / modules / menu_test / src / TestControllers.php
1 <?php
2
3 namespace Drupal\menu_test;
4
5 use Drupal\Component\Render\FormattableMarkup;
6
7 /**
8  * Controllers for testing the menu integration routing system.
9  */
10 class TestControllers {
11
12   /**
13    * Returns page to be used as a login path.
14    */
15   public function testLogin() {
16     return ['#markup' => 'This is TestControllers::testLogin.'];
17   }
18
19   /**
20    * Prints out test data.
21    */
22   public function test1() {
23     return ['#markup' => 'test1'];
24   }
25
26   /**
27    * Prints out test data.
28    */
29   public function test2() {
30     return ['#markup' => 'test2'];
31   }
32
33   /**
34    * Prints out test data.
35    */
36   public function testSession() {
37     if (!isset($_SESSION['menu_test'])) {
38       $_SESSION['menu_test'] = 0;
39     }
40     $_SESSION['menu_test']++;
41     return ['#markup' => new FormattableMarkup('Session menu_test is @count', ['@count' => $_SESSION['menu_test']])];
42   }
43
44   /**
45    * Prints out test data.
46    */
47   public function testDerived() {
48     return ['#markup' => 'testDerived'];
49   }
50
51   /**
52    * Prints out test data.
53    *
54    * @param string|null $placeholder
55    *   A placeholder for the return string.
56    *
57    * @return string
58    *   The string for this route.
59    */
60   public function testDefaults($placeholder = NULL) {
61     if ($placeholder) {
62       return ['#markup' => new FormattableMarkup("Sometimes there is a placeholder: '@placeholder'.", ['@placeholder' => $placeholder])];
63     }
64     else {
65       return ['#markup' => 'Sometimes there is no placeholder.'];
66     }
67   }
68
69   /**
70    * Prints out test data with contextual links.
71    */
72   public function testContextual() {
73     return [
74       '#markup' => 'testContextual',
75       'stuff' => [
76         '#type' => 'contextual_links',
77         '#contextual_links' => [
78           'menu_test_menu' => [
79             'route_parameters' => ['bar' => 1],
80           ],
81         ],
82       ],
83     ];
84   }
85
86 }