function state_flow_node_revision_operation_change_state_batch_process in State Machine 7.2
Same name and namespace in other branches
- 7.3 modules/state_flow/state_flow.module \state_flow_node_revision_operation_change_state_batch_process()
State Change Mass Update Batch operation
1 string reference to 'state_flow_node_revision_operation_change_state_batch_process'
- state_flow_node_revision_operation_change_state in modules/
state_flow/ state_flow.module - Operation callback to change state of a node
File
- modules/
state_flow/ state_flow.module, line 707 - An implementation of node revision workflow for Drupal based on the State Machine system.
Code
function state_flow_node_revision_operation_change_state_batch_process($nodes, $updates, &$context) {
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = count($nodes);
$context['sandbox']['nodes'] = $nodes;
}
// Process nodes by groups of 5.
$count = min(5, count($context['sandbox']['nodes']));
for ($i = 1; $i <= $count; $i++) {
// For each nid, load the node, reset the values, and save it.
$info = array_shift($context['sandbox']['nodes']);
// Store result for post-processing in the finished callback.
$context['results'][] = state_flow_operation_change_helper($info, $updates['event']);
// Update our progress information.
$context['sandbox']['progress']++;
}
// Inform the batch engine that we are not finished,
// and provide an estimation of the completion level we reached.
if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
}
}