function CKEditor5DialogTestController::testDialog

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/modules/ckeditor5_test/src/Controller/CKEditor5DialogTestController.php \Drupal\ckeditor5_test\Controller\CKEditor5DialogTestController::testDialog()
  2. 11.x core/modules/ckeditor5/tests/modules/ckeditor5_test/src/Controller/CKEditor5DialogTestController.php \Drupal\ckeditor5_test\Controller\CKEditor5DialogTestController::testDialog()

Returns a link that can open a node add form in an modal dialog.

Return value

array A render array.

1 string reference to 'CKEditor5DialogTestController::testDialog'
ckeditor5_test.routing.yml in core/modules/ckeditor5/tests/modules/ckeditor5_test/ckeditor5_test.routing.yml
core/modules/ckeditor5/tests/modules/ckeditor5_test/ckeditor5_test.routing.yml

File

core/modules/ckeditor5/tests/modules/ckeditor5_test/src/Controller/CKEditor5DialogTestController.php, line 21

Class

CKEditor5DialogTestController
Provides controller for testing CKEditor in off-canvas dialogs.

Namespace

Drupal\ckeditor5_test\Controller

Code

public function testDialog() {
    $build['link'] = [
        '#type' => 'link',
        '#title' => 'Add Node',
        '#url' => Url::fromRoute('node.add', [
            'node_type' => 'page',
        ]),
        '#attributes' => [
            'class' => [
                'use-ajax',
            ],
            'data-dialog-type' => 'dialog',
            'data-dialog-options' => Json::encode([
                'width' => 700,
                'modal' => TRUE,
                'autoResize' => TRUE,
            ]),
        ],
    ];
    $build['#attached']['library'][] = 'core/drupal.dialog.ajax';
    // Add this library to prevent Modernizr from triggering a deprecation
    // notice during testing.
    // @todo remove in https://www.drupal.org/project/drupal/issues/3269082.
    $build['#attached']['library'][] = 'core/drupal.touchevents-test';
    return $build;
}

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