summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-02-09 11:56:53 (GMT)
committerAlex Pott2015-02-09 11:56:53 (GMT)
commitaf1ea7bfb08374e4e8398994f431d08b525ca5ad (patch)
tree3a392b0e4c4812cffcb68ebe485de83425f5e713
parenta4df58b1d8fa9cc00a94bcc27e573ad4589d9519 (diff)
Issue #2066445 by mparker17, rpayanm, aspilicious, tkuldeep17, adci_contributor, Mile23, vijaycs85, alvar0hurtad0, rahulbile, andypost, valthebald: Convert a bunch of AjaxResponse callbacks in system.module's test's ajax_test.module to a new style controller
-rw-r--r--core/modules/system/tests/modules/ajax_test/ajax_test.module40
-rw-r--r--core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php33
2 files changed, 27 insertions, 46 deletions
diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module
deleted file mode 100644
index de741fe..0000000
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.module
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/**
- * @file
- * Helper module for Ajax framework tests.
- */
-
-use Drupal\Core\Ajax\AjaxResponse;
-use Drupal\Core\Ajax\AlertCommand;
-use Drupal\Core\Ajax\OpenDialogCommand;
-use Drupal\Core\Ajax\OpenModalDialogCommand;
-use Drupal\Core\Ajax\CloseDialogCommand;
-use Drupal\Core\Url;
-
-/**
- * Menu callback: Returns AJAX element with #error property set.
- *
- * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::renderError()
- */
-function ajax_test_error() {
- $message = '';
- $query = \Drupal::request()->query;
- if ($query->has('message')) {
- $message = $query->get('message');
- }
- $response = new AjaxResponse();
- $response->addCommand(new AlertCommand($message));
- return $response;
-}
-
-/**
- * Menu callback: Close the ajax dialog.
- *
- * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::dialogClose()
- */
-function ajax_test_dialog_close() {
- $response = new AjaxResponse();
- $response->addCommand(new CloseDialogCommand('#ajax-test-dialog-wrapper-1'));
- return $response;
-}
diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
index 928b84e..b54b823 100644
--- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
@@ -8,8 +8,11 @@
namespace Drupal\ajax_test\Controller;
use Drupal\Core\Ajax\AjaxResponse;
+use Drupal\Core\Ajax\AlertCommand;
+use Drupal\Core\Ajax\CloseDialogCommand;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Url;
+use Symfony\Component\HttpFoundation\Request;
/**
* Provides content for dialog tests.
@@ -80,14 +83,27 @@ class AjaxTestController {
}
/**
- * @todo Remove ajax_test_error().
+ * Returns an AjaxResponse with alert command.
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The current request object.
+ *
+ * @return \Drupal\Core\Ajax\AjaxResponse
+ * The JSON response object.
*/
- public function renderError() {
- return ajax_test_error();
+ public function renderError(Request $request) {
+ $message = '';
+ $query = $request->query;
+ if ($query->has('message')) {
+ $message = $query->get('message');
+ }
+ $response = new AjaxResponse();
+ $response->addCommand(new AlertCommand($message));
+ return $response;
}
/**
- * @todo Remove ajax_test_dialog().
+ * Returns a render array of form elements and links for dialog.
*/
public function dialog() {
// Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
@@ -180,10 +196,15 @@ class AjaxTestController {
}
/**
- * @todo Remove ajax_test_dialog_close().
+ * Returns an AjaxResponse with command to close dialog.
+ *
+ * @return \Drupal\Core\Ajax\AjaxResponse
+ * The JSON response object.
*/
public function dialogClose() {
- return ajax_test_dialog_close();
+ $response = new AjaxResponse();
+ $response->addCommand(new CloseDialogCommand('#ajax-test-dialog-wrapper-1'));
+ return $response;
}
}