function TestController::linksDisplay

Same name in this branch
  1. 11.x core/modules/system/tests/modules/dialog_renderer_test/src/Controller/TestController.php \Drupal\dialog_renderer_test\Controller\TestController::linksDisplay()
Same name in other branches
  1. 9 core/modules/system/tests/modules/dialog_renderer_test/src/Controller/TestController.php \Drupal\dialog_renderer_test\Controller\TestController::linksDisplay()
  2. 9 core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php \Drupal\off_canvas_test\Controller\TestController::linksDisplay()
  3. 8.9.x core/modules/system/tests/modules/dialog_renderer_test/src/Controller/TestController.php \Drupal\dialog_renderer_test\Controller\TestController::linksDisplay()
  4. 8.9.x core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php \Drupal\off_canvas_test\Controller\TestController::linksDisplay()
  5. 10 core/modules/system/tests/modules/dialog_renderer_test/src/Controller/TestController.php \Drupal\dialog_renderer_test\Controller\TestController::linksDisplay()
  6. 10 core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php \Drupal\off_canvas_test\Controller\TestController::linksDisplay()

Displays test links that will open in off-canvas dialog.

Return value

array Render array with links.

1 string reference to 'TestController::linksDisplay'
off_canvas_test.routing.yml in core/modules/system/tests/modules/off_canvas_test/off_canvas_test.routing.yml
core/modules/system/tests/modules/off_canvas_test/off_canvas_test.routing.yml

File

core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php, line 47

Class

TestController
Test controller for 2 different responses.

Namespace

Drupal\off_canvas_test\Controller

Code

public function linksDisplay() {
    return [
        'off_canvas_link_1' => [
            '#title' => 'Open side panel 1',
            '#type' => 'link',
            '#url' => Url::fromRoute('off_canvas_test.thing1'),
            '#attributes' => [
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'dialog',
                'data-dialog-renderer' => 'off_canvas',
                'data-dialog-options' => Json::encode([
                    'classes' => [
                        "ui-dialog" => "ui-corner-all side-1",
                    ],
                ]),
            ],
        ],
        'off_canvas_link_2' => [
            '#title' => 'Open side panel 2',
            '#type' => 'link',
            '#url' => Url::fromRoute('off_canvas_test.thing2'),
            '#attributes' => [
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'dialog',
                'data-dialog-renderer' => 'off_canvas',
                'data-dialog-options' => Json::encode([
                    'width' => 555,
                    'classes' => [
                        "ui-dialog" => "ui-corner-all side-2",
                    ],
                ]),
            ],
        ],
        'off_canvas_top_link_1' => [
            '#title' => 'Open top panel 1',
            '#type' => 'link',
            '#url' => Url::fromRoute('off_canvas_test.thing1'),
            '#attributes' => [
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'dialog',
                'data-dialog-renderer' => 'off_canvas_top',
                'data-dialog-options' => Json::encode([
                    'width' => 555,
                    'classes' => [
                        "ui-dialog" => "ui-corner-all top-1",
                    ],
                ]),
            ],
        ],
        'off_canvas_top_link_2' => [
            '#title' => 'Open top panel 2',
            '#type' => 'link',
            '#url' => Url::fromRoute('off_canvas_test.thing2'),
            '#attributes' => [
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'dialog',
                'data-dialog-renderer' => 'off_canvas_top',
                'data-dialog-options' => Json::encode([
                    'height' => 421,
                    'classes' => [
                        "ui-dialog" => "ui-corner-all top-2",
                    ],
                ]),
            ],
        ],
        'other_dialog_links' => [
            '#title' => 'Display more links!',
            '#type' => 'link',
            '#url' => Url::fromRoute('off_canvas_test.dialog_links'),
            '#attributes' => [
                'class' => [
                    'use-ajax',
                ],
                'data-dialog-type' => 'dialog',
                'data-dialog-renderer' => 'off_canvas',
            ],
        ],
        '#attached' => [
            'library' => [
                'core/drupal.dialog.ajax',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.