function _background_batch_operation in Background Process 7.2
Same name and namespace in other branches
- 8 background_batch/background_batch.module \_background_batch_operation()
- 6 background_batch/background_batch.module \_background_batch_operation()
- 7 background_batch/background_batch.module \_background_batch_operation()
Run a batch operation with "listening" context.
Parameters
$operation: Batch operation definition.
&$context: Context for the batch operation.
1 string reference to '_background_batch_operation'
- background_batch_batch_alter in background_batch/
background_batch.module - Implements hook_batch_alter(). Steal the operation and hook into context data.
File
- background_batch/
background_batch.module, line 129 - This module adds background processing to Drupals batch API
Code
function _background_batch_operation($operation, &$context) {
// Steal context and trap finished variable
$fine_progress = !empty($context['sandbox']['background_batch_fine_progress']);
if ($fine_progress) {
$batch_context = new BackgroundBatchContext($context);
}
else {
$batch_context = $context;
}
// Call the original operation
$operation[1][] =& $batch_context;
call_user_func_array($operation[0], $operation[1]);
if ($fine_progress) {
// Transfer back context result to batch api
$batch_context = (array) $batch_context;
foreach (array_keys($batch_context) as $key) {
$context[$key] = $batch_context[$key];
}
}
else {
$batch_context = new BackgroundBatchContext($context);
$batch_context['finished'] = $context['finished'];
}
}