853c620dc23c83488144d17cd93ae7d9e2a63444
[yaffs-website] / web / core / modules / system / tests / modules / dialog_renderer_test / src / Controller / TestController.php
1 <?php
2
3 namespace Drupal\dialog_renderer_test\Controller;
4
5 use Drupal\Core\Url;
6
7 /**
8  * Test controller display modal links and content.
9  */
10 class TestController {
11
12   /**
13    * Return modal content.
14    *
15    * @return array
16    *   Render array for display in modal.
17    */
18   public function modalContent() {
19     return [
20       '#type' => 'markup',
21       '#markup' => 'Look at me in a modal!',
22     ];
23   }
24
25   /**
26    * Displays test links that will open in the modal dialog.
27    *
28    * @return array
29    *   Render array with links.
30    */
31   public function linksDisplay() {
32     return [
33       'normal_modal' => [
34         '#title' => 'Normal Modal!',
35         '#type' => 'link',
36         '#url' => Url::fromRoute('dialog_renderer_test.modal_content'),
37         '#attributes' => [
38           'class' => ['use-ajax'],
39           'data-dialog-type' => 'modal',
40         ],
41         '#attached' => [
42           'library' => [
43             'core/drupal.ajax',
44           ],
45         ],
46       ],
47       'wide_modal' => [
48         '#title' => 'Wide Modal!',
49         '#type' => 'link',
50         '#url' => Url::fromRoute('dialog_renderer_test.modal_content'),
51         '#attributes' => [
52           'class' => ['use-ajax'],
53           'data-dialog-type' => 'modal',
54           'data-dialog-renderer' => 'wide',
55         ],
56         '#attached' => [
57           'library' => [
58             'core/drupal.ajax',
59           ],
60         ],
61       ],
62       'extra_wide_modal' => [
63         '#title' => 'Extra Wide Modal!',
64         '#type' => 'link',
65         '#url' => Url::fromRoute('dialog_renderer_test.modal_content'),
66         '#attributes' => [
67           'class' => ['use-ajax'],
68           'data-dialog-type' => 'modal',
69           'data-dialog-renderer' => 'extra_wide',
70         ],
71         '#attached' => [
72           'library' => [
73             'core/drupal.ajax',
74           ],
75         ],
76       ],
77     ];
78   }
79
80 }