Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / modules / views_test_modal / src / Controller / TestController.php
diff --git a/web/core/modules/views/tests/modules/views_test_modal/src/Controller/TestController.php b/web/core/modules/views/tests/modules/views_test_modal/src/Controller/TestController.php
new file mode 100644 (file)
index 0000000..b89cf40
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+
+namespace Drupal\views_test_modal\Controller;
+
+use Drupal\Component\Serialization\Json;
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Url;
+
+class TestController extends ControllerBase {
+
+  /**
+   * Renders a link to open the /admin/content view in a modal dialog.
+   */
+  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;
+  }
+
+}