diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 42843fa..dacf778 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -305,6 +305,8 @@ function ajax_render($commands = array()) { * This will load a form from the form cache used during Ajax operations. It * pulls the form info from $_POST. * + * TODO: Move to AjaxController + * * @return * An array containing the $form and $form_state. Use the list() function * to break these apart: @@ -315,6 +317,7 @@ function ajax_render($commands = array()) { function ajax_get_form() { $form_state = form_state_defaults(); + // TODO: Get this from the request object. $form_build_id = $_POST['form_build_id']; // Get the form from the cache. @@ -340,6 +343,7 @@ function ajax_get_form() { // The form needs to be processed; prepare for that by setting a few internal // variables. + // TODO: Get this from the request object. $form_state['input'] = $_POST; $form_id = $form['#form_id']; @@ -347,41 +351,6 @@ function ajax_get_form() { } /** - * Page callback: Handles Ajax requests for the #ajax Form API property. - * - * This rebuilds the form from cache and invokes the defined #ajax['callback'] - * to return an Ajax command structure for JavaScript. In case no 'callback' has - * been defined, nothing will happen. - * - * The Form API #ajax property can be set both for buttons and other input - * elements. - * - * This function is also the canonical example of how to implement - * #ajax['path']. If processing is required that cannot be accomplished with - * a callback, re-implement this function and set #ajax['path'] to the - * enhanced function. - * - * @see system_menu() - */ -function ajax_form_callback() { - list($form, $form_state) = ajax_get_form(); - drupal_process_form($form['#form_id'], $form, $form_state); - - // We need to return the part of the form (or some other content) that needs - // to be re-rendered so the browser can update the page with changed content. - // Since this is the generic menu callback used by many Ajax elements, it is - // up to the #ajax['callback'] function of the element (may or may not be a - // button) that triggered the Ajax request to determine what needs to be - // rendered. - if (!empty($form_state['triggering_element'])) { - $callback = $form_state['triggering_element']['#ajax']['callback']; - } - if (!empty($callback) && is_callable($callback)) { - return call_user_func_array($callback, array(&$form, &$form_state)); - } -} - -/** * Theme callback: Returns the correct theme for an Ajax request. * * Many different pages can invoke an Ajax request to system/ajax or another diff --git a/core/modules/system/lib/Drupal/system/AjaxController.php b/core/modules/system/lib/Drupal/system/AjaxController.php new file mode 100644 index 0000000..392a6af --- /dev/null +++ b/core/modules/system/lib/Drupal/system/AjaxController.php @@ -0,0 +1,40 @@ + 'AHAH callback', - 'page callback' => 'ajax_form_callback', - 'access callback' => TRUE, + 'route_name' => 'system.ajax', 'theme callback' => 'ajax_base_page_theme', 'type' => MENU_CALLBACK, 'file path' => 'core/includes', diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index b285844..3a58d9f 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -1,3 +1,9 @@ +system.ajax: + pattern: 'system/ajax' + defaults: + _controller: '\Drupal\system\AjaxController::formAhah' + requirements: + _access: 'TRUE' system.cron: pattern: '/cron/{key}' defaults: