function rb_batch_operation_rule_evaluate in Rules Bonus Pack 7
Batch operation which will take over execution of each rule.
1 string reference to 'rb_batch_operation_rule_evaluate'
- BatchedRuleSet::evaluate in rb_batch/
rb_batch.rules.inc - Evaluate, whereas by default new vars are visible in the parent's scope.
File
- rb_batch/
rb_batch.module, line 13 - Provides a batched rule set component to rules.
Code
function rb_batch_operation_rule_evaluate($rule, RulesState $initial_state, &$context) {
// Check wether we have use the initial state or is there already a modified
// state in batch's runtime context, otherwise initial state is used.
$state = isset($context['results']['state']) ? $context['results']['state'] : $initial_state;
// Execute rule evaluation.
$rule
->evaluate($state);
// Save current rules state for later batch operations.
$context['results']['state'] = $state;
// Check wether there are context changes made by "Alter batch context"
// action. Parameters of the actions call would be saved in rules state.
$context['message'] = isset($state->currentArguments['batch_context_message']) ? $state->currentArguments['batch_context_message'] : $rule->label;
$context['finished'] = isset($state->currentArguments['batch_context_finished']) ? $state->currentArguments['batch_context_finished'] : TRUE;
// Clean up, to make shure that everything processed will be saved.
$state
->cleanUp($rule);
}