_batch_page(Request $request)
Renders the batch processing page based on the current state of the batch.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request object.
See also
File
- core/includes/batch.inc, line 34
- Batch processing API for processes to run in multiple HTTP requests.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | function _batch_page(Request $request ) { $batch = &batch_get(); if (!( $request_id = $request ->query->get( 'id' ))) { return FALSE; } // Retrieve the current state of the batch. if (! $batch ) { $batch = \Drupal::service( 'batch.storage' )->load( $request_id ); if (! $batch ) { drupal_set_message(t( 'No active batch.' ), 'error' ); return new RedirectResponse(\Drupal::url( '<front>' , [], [ 'absolute' => TRUE])); } } // Register database update for the end of processing. drupal_register_shutdown_function( '_batch_shutdown' ); $build = array (); // Add batch-specific libraries. foreach ( $batch [ 'sets' ] as $batch_set ) { if (isset( $batch_set [ 'library' ])) { foreach ( $batch_set [ 'library' ] as $library ) { $build [ '#attached' ][ 'library' ][] = $library ; } } } $op = $request ->query->get( 'op' , '' ); switch ( $op ) { case 'start' : case 'do_nojs' : // Display the full progress page on startup and on each additional // non-JavaScript iteration. $current_set = _batch_current_set(); $build [ '#title' ] = $current_set [ 'title' ]; $build [ 'content' ] = _batch_progress_page(); break ; case 'do' : // JavaScript-based progress page callback. return _batch_do(); case 'finished' : // _batch_finished() returns a RedirectResponse. return _batch_finished(); } return $build ; } |
Please login to continue.