Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / settings_tray / tests / modules / off_canvas_test / src / Controller / TestController.php
1 <?php
2
3 namespace Drupal\off_canvas_test\Controller;
4
5 use Drupal\Component\Serialization\Json;
6 use Drupal\Core\Url;
7
8 /**
9  * Test controller for 2 different responses.
10  */
11 class TestController {
12
13   /**
14    * Thing1.
15    *
16    * @return string
17    *   Return Hello string.
18    */
19   public function thing1() {
20     return [
21       '#type' => 'markup',
22       '#markup' => 'Thing 1 says hello',
23     ];
24   }
25
26   /**
27    * Thing2.
28    *
29    * @return string
30    *   Return Hello string.
31    */
32   public function thing2() {
33     return [
34       '#type' => 'markup',
35       '#markup' => 'Thing 2 says hello',
36     ];
37   }
38
39   /**
40    * Displays test links that will open in off-canvas dialog.
41    *
42    * @return array
43    *   Render array with links.
44    */
45   public function linksDisplay() {
46     return [
47       'off_canvas_link_1' => [
48         '#title' => 'Click Me 1!',
49         '#type' => 'link',
50         '#url' => Url::fromRoute('off_canvas_test.thing1'),
51         '#attributes' => [
52           'class' => ['use-ajax'],
53           'data-dialog-type' => 'dialog',
54           'data-dialog-renderer' => 'off_canvas',
55         ],
56         '#attached' => [
57           'library' => [
58             'settings_tray/drupal.settings_tray',
59           ],
60         ],
61       ],
62       'off_canvas_link_2' => [
63         '#title' => 'Click Me 2!',
64         '#type' => 'link',
65         '#url' => Url::fromRoute('off_canvas_test.thing2'),
66         '#attributes' => [
67           'class' => ['use-ajax'],
68           'data-dialog-type' => 'dialog',
69           'data-dialog-renderer' => 'off_canvas',
70           'data-dialog-options' => Json::encode([
71             'width' => 555,
72           ]),
73         ],
74         '#attached' => [
75           'library' => [
76             'settings_tray/drupal.settings_tray',
77           ],
78         ],
79       ],
80       'other_dialog_links' => [
81         '#title' => 'Display more links!',
82         '#type' => 'link',
83         '#url' => Url::fromRoute('off_canvas_test.dialog_links'),
84         '#attributes' => [
85           'class' => ['use-ajax'],
86           'data-dialog-type' => 'dialog',
87           'data-dialog-renderer' => 'off_canvas',
88         ],
89         '#attached' => [
90           'library' => [
91             'settings_tray/drupal.settings_tray',
92           ],
93         ],
94       ],
95     ];
96   }
97
98   /**
99    * Displays dialogs links to be displayed inside the off-canvas dialog.
100    *
101    * This links are used to test opening a modal and another off_canvas link from
102    * inside the off-canvas dialog.
103    *
104    * @todo Update tests to check these links work in the off-canvas dialog.
105    *       https://www.drupal.org/node/2790073
106    *
107    * @return array
108    *   Render array with links.
109    */
110   public function otherDialogLinks() {
111     return [
112       '#theme' => 'links',
113       '#links' => [
114         'modal_link' => [
115           'title' => 'Open modal!',
116           'url' => Url::fromRoute('off_canvas_test.thing2'),
117           'attributes' => [
118             'class' => ['use-ajax'],
119             'data-dialog-type' => 'modal',
120           ],
121         ],
122         'off_canvas_link' => [
123           'title' => 'Off_canvas link!',
124           'url' => Url::fromRoute('off_canvas_test.thing2'),
125           'attributes' => [
126             'class' => ['use-ajax'],
127             'data-dialog-type' => 'dialog',
128             'data-dialog-renderer' => 'off_canvas',
129           ],
130         ],
131       ],
132       '#attached' => [
133         'library' => [
134           'settings_tray/drupal.settings_tray',
135         ],
136       ],
137     ];
138   }
139
140 }