Update Batch API to return a JSON response directly from the controller, and from _batch_do().
parent
25ea4a1f4a
commit
a001caf29f
|
@ -14,6 +14,8 @@
|
|||
* @see batch_get()
|
||||
*/
|
||||
|
||||
use \Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* Loads a batch from the database.
|
||||
*
|
||||
|
@ -77,7 +79,7 @@ function _batch_page() {
|
|||
|
||||
case 'do':
|
||||
// JavaScript-based progress page callback.
|
||||
_batch_do();
|
||||
$output = _batch_do();
|
||||
break;
|
||||
|
||||
case 'do_nojs':
|
||||
|
@ -160,7 +162,7 @@ function _batch_do() {
|
|||
// Perform actual processing.
|
||||
list($percentage, $message) = _batch_process();
|
||||
|
||||
drupal_json_output(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
|
||||
return new JsonResponse(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Admin page callbacks for the system module.
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Menu callback; Provide the administration overview page.
|
||||
*/
|
||||
|
@ -2358,6 +2360,9 @@ function system_batch_page() {
|
|||
if ($output === FALSE) {
|
||||
drupal_access_denied();
|
||||
}
|
||||
elseif ($output instanceof Response) {
|
||||
return $output;
|
||||
}
|
||||
elseif (isset($output)) {
|
||||
// Force a page without blocks or messages to
|
||||
// display a list of collected messages later.
|
||||
|
|
Loading…
Reference in New Issue