function _batch_page in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/batch.inc \_batch_page()
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
4 calls to _batch_page()
- authorize.php in core/
authorize.php - Administrative script for running authorized file operations.
- BatchController::batchPage in core/
modules/ system/ src/ Controller/ BatchController.php - Returns a system batch page.
- DbUpdateController::handle in core/
modules/ system/ src/ Controller/ DbUpdateController.php - Returns a database update page.
- install_run_task in core/
includes/ install.core.inc - Runs an individual installation task.
File
- core/
includes/ batch.inc, line 34 - Batch processing API for processes to run in multiple HTTP requests.
Code
function _batch_page(Request $request) {
$batch =& batch_get();
if (!($request_id = $request
->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
->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;
}