From ab06f5ff89096782b16610c76b2d4917b7328119 Mon Sep 17 00:00:00 2001 From: M Parker Date: Wed, 25 Jun 2014 21:23:10 -0400 Subject: [PATCH] 2066445-26 --- .../tests/modules/ajax_test/ajax_test.module | 95 ---------------------- .../src/Controller/AjaxTestController.php | 81 +++++++++++++++--- 2 files changed, 69 insertions(+), 107 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 index eee24f3..ea50f7d 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -5,90 +5,6 @@ * 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; - -/** - * 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( - 'js' => array( - 0 => array( - 'type' => 'setting', - 'data' => array('ajax' => 'test'), - ), - ), - ), - ); - drupal_render($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(); - $path = drupal_get_path('module', 'system'); - // HTML insertion command. - $response->addCommand(new HtmlCommand('body', 'Hello, world!')); - $attached = array( - '#attached' => array( - 'css' => array( - // Add two CSS files (order should remain the same). - $path . '/css/system.admin.css' => array(), - $path . '/css/system.maintenance.css' => array(), - ), - 'js' => array( - // Add two JavaScript files (first to the footer, should appear last). - $path . '/system.modules.js' => array('scope' => 'footer'), - $path . '/system.js' => array(), - // Finally, add a JavaScript setting. - 0 => array( - 'type' => 'setting', - 'data' => array('ajax' => 'test'), - ), - ), - ), - ); - drupal_render($attached); - 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. */ @@ -113,14 +29,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 ac0399f..e6772a2 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,11 @@ namespace Drupal\ajax_test\Controller; +use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\AlertCommand; +use Drupal\Core\Ajax\HtmlCommand; +use Drupal\Core\Ajax\CloseDialogCommand; + /** * Provides content for dialog tests. */ @@ -17,32 +22,81 @@ 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( + 'js' => array( + 0 => array( + 'type' => 'setting', + 'data' => array('ajax' => 'test'), + ), + ), + ), + ); + drupal_render($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(); + $path = drupal_get_path('module', 'system'); + // HTML insertion command. + $response->addCommand(new HtmlCommand('body', 'Hello, world!')); + $attached = array( + '#attached' => array( + 'css' => array( + // Add two CSS files (order should remain the same). + $path . '/css/system.admin.css' => array(), + $path . '/css/system.maintenance.css' => array(), + ), + 'js' => array( + // Add two JavaScript files (first to the footer, should appear last). + $path . '/system.modules.js' => array('scope' => 'footer'), + $path . '/system.js' => array(), + // Finally, add a JavaScript setting. + 0 => array( + 'type' => 'setting', + 'data' => array('ajax' => 'test'), + ), + ), + ), + ); + drupal_render($attached); + 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 @@ -135,10 +189,13 @@ 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; } } -- 1.9.1