diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module index d81da66..5be5911 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -5,73 +5,9 @@ * 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\Ajax\HtmlCommand; use Drupal\Core\Url; /** - * Menu callback: Returns an element suitable for use by - * \Drupal\Core\Ajax\AjaxResponse::ajaxRender(). - * - * Additionally ensures that \Drupal\Core\Ajax\AjaxResponse::ajaxRender() - * incorporates JavaScript settings generated during the page request by - * invoking _drupal_add_js() with a dummy setting. - * - * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::render() - */ -function ajax_test_render() { - $attached = array( - '#attached' => array( - 'drupalSettings' => array( - 'ajax' => 'test', - ), - ), - ); - // @todo Why is this being tested via an explicit drupal_render() call? - drupal_render($attached); - drupal_process_attached($attached); - $response = new AjaxResponse(); - return $response; -} - -/** - * Menu callback: Returns an AjaxResponse; settings command set last. - * - * Helps verifying AjaxResponse reorders commands to ensure correct execution. - * - * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::order() - */ -function ajax_test_order() { - $response = new AjaxResponse(); - // HTML insertion command. - $response->addCommand(new HtmlCommand('body', 'Hello, world!')); - $build['#attached']['library'][] = 'ajax_test/order'; - drupal_process_attached($build); - - return $response; -} - -/** - * 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; -} - -/** * Returns example content for dialog tests. */ function ajax_test_dialog_contents() { @@ -95,14 +31,3 @@ function ajax_test_dialog_contents() { return $content; } - -/** - * 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 ab25fde..fc85b2c 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 @@ -7,6 +7,10 @@ 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; /** @@ -19,32 +23,62 @@ class AjaxTestController { */ public function dialogContents() { // Re-use the utility method that returns the example content. + // This is a regular render array; the keys do not have special meaning. return ajax_test_dialog_contents(); } /** - * @todo Remove ajax_test_render(). + *Returns an element suitable for use by + * \Drupal\Core\Ajax\AjaxResponse::ajaxRender(). + * Additionally ensures that \Drupal\Core\Ajax\AjaxResponse::ajaxRender() + * incorporates JavaScript settings generated during the page request by + * invoking _drupal_add_js() with a dummy setting. */ public function render() { - return ajax_test_render(); + $attached = array( + '#attached' => array( + 'drupalSettings' => array( + 'ajax' => 'test', + ), + ), + ); + // @todo Why is this being tested via an explicit drupal_render() call? + drupal_render($attached); + drupal_process_attached($attached); + $response = new AjaxResponse(); + return $response; } /** - * @todo Remove ajax_test_order(). + * Returns an AjaxResponse; settings command set last. + * Helps verifying AjaxResponse reorders commands to ensure correct execution. */ public function order() { - return ajax_test_order(); + $response = new AjaxResponse(); + // HTML insertion command. + $response->addCommand(new HtmlCommand('body', 'Hello, world!')); + $build['#attached']['library'][] = 'ajax_test/order'; + drupal_process_attached($build); + + return $response; } /** - * @todo Remove ajax_test_error(). + * Menu callback: Returns AJAX element with #error property set. */ public function renderError() { - return 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; } /** - * @todo Remove ajax_test_dialog(). + * */ public function dialog() { // Add two wrapper elements for testing non-modal dialogs. Modal dialogs use @@ -137,10 +171,12 @@ public function dialog() { } /** - * @todo Remove ajax_test_dialog_close(). + * Close the ajax dialog. */ public function dialogClose() { - return ajax_test_dialog_close(); + $response = new AjaxResponse(); + $response->addCommand(new CloseDialogCommand('#ajax-test-dialog-wrapper-1')); + return $response; } }