3 namespace Drupal\off_canvas_test\Controller;
5 use Drupal\Component\Serialization\Json;
9 * Test controller for 2 different responses.
11 class TestController {
17 * Return Hello string.
19 public function thing1() {
22 '#markup' => 'Thing 1 says hello',
30 * Return Hello string.
32 public function thing2() {
35 '#markup' => 'Thing 2 says hello',
40 * Displays test links that will open in off-canvas dialog.
43 * Render array with links.
45 public function linksDisplay() {
47 'off_canvas_link_1' => [
48 '#title' => 'Click Me 1!',
50 '#url' => Url::fromRoute('off_canvas_test.thing1'),
52 'class' => ['use-ajax'],
53 'data-dialog-type' => 'dialog',
54 'data-dialog-renderer' => 'off_canvas',
58 'outside_in/drupal.outside_in',
62 'off_canvas_link_2' => [
63 '#title' => 'Click Me 2!',
65 '#url' => Url::fromRoute('off_canvas_test.thing2'),
67 'class' => ['use-ajax'],
68 'data-dialog-type' => 'dialog',
69 'data-dialog-renderer' => 'off_canvas',
70 'data-dialog-options' => Json::encode([
76 'outside_in/drupal.outside_in',
80 'other_dialog_links' => [
81 '#title' => 'Display more links!',
83 '#url' => Url::fromRoute('off_canvas_test.dialog_links'),
85 'class' => ['use-ajax'],
86 'data-dialog-type' => 'dialog',
87 'data-dialog-renderer' => 'off_canvas',
91 'outside_in/drupal.outside_in',
99 * Displays dialogs links to be displayed inside the off-canvas dialog.
101 * This links are used to test opening a modal and another off_canvas link from
102 * inside the off-canvas dialog.
104 * @todo Update tests to check these links work in the off-canvas dialog.
105 * https://www.drupal.org/node/2790073
108 * Render array with links.
110 public function otherDialogLinks() {
115 'title' => 'Open modal!',
116 'url' => Url::fromRoute('off_canvas_test.thing2'),
118 'class' => ['use-ajax'],
119 'data-dialog-type' => 'modal',
122 'off_canvas_link' => [
123 'title' => 'Off_canvas link!',
124 'url' => Url::fromRoute('off_canvas_test.thing2'),
126 'class' => ['use-ajax'],
127 'data-dialog-type' => 'dialog',
128 'data-dialog-renderer' => 'off_canvas',
134 'outside_in/drupal.outside_in',