You are here

public function TestController::modal in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/modules/views_test_modal/src/Controller/TestController.php \Drupal\views_test_modal\Controller\TestController::modal()
  2. 10 core/modules/views/tests/modules/views_test_modal/src/Controller/TestController.php \Drupal\views_test_modal\Controller\TestController::modal()

Renders a link to open the /admin/content view in a modal dialog.

1 string reference to 'TestController::modal'
views_test_modal.routing.yml in core/modules/views/tests/modules/views_test_modal/views_test_modal.routing.yml
core/modules/views/tests/modules/views_test_modal/views_test_modal.routing.yml

File

core/modules/views/tests/modules/views_test_modal/src/Controller/TestController.php, line 14

Class

TestController

Namespace

Drupal\views_test_modal\Controller

Code

public function modal() {
  $build = [];
  $build['open_admin_content'] = [
    '#type' => 'link',
    '#title' => $this
      ->t('Administer content'),
    '#url' => Url::fromUserInput('/admin/content'),
    '#attributes' => [
      'class' => [
        'use-ajax',
      ],
      'data-dialog-type' => 'modal',
      'data-dialog-options' => Json::encode([
        'dialogClass' => 'views-test-modal',
        'height' => '50%',
        'width' => '50%',
        'title' => $this
          ->t('Administer content'),
      ]),
    ],
    '#attached' => [
      'library' => [
        'core/drupal.dialog.ajax',
      ],
    ],
  ];
  return $build;
}