You are here

public function BatchedRuleSet::evaluate in Rules Bonus Pack 7

Evaluate, whereas by default new vars are visible in the parent's scope.

Overrides RulesActionContainer::evaluate

File

rb_batch/rb_batch.rules.inc, line 40
Provides a batched rule set component to rules.

Class

BatchedRuleSet
A set of rules to execute upon defined variables, within the possibility of executing each rule as batch operation.

Code

public function evaluate(RulesState $state) {
  rules_log('Taking over %label to batch API.', array(
    '%label' => $this->label,
  ), RulesLog::INFO, NULL, TRUE);

  // Take over further evaluation through batch.
  $operations = array();

  // Create an array containing the static operational function
  // and provide them each rule within the initial rules state.
  foreach ($this->children as $rule) {
    $operations[] = array(
      'rb_batch_operation_rule_evaluate',
      array(
        $rule,
        $state,
      ),
    );
  }

  // This will set the batch to be executed (on the next site).
  batch_set(array(
    'operations' => $operations,
  ));
  rules_log('Finished takeover %label.', array(
    '%label' => $this->label,
  ), RulesLog::INFO, NULL, FALSE);
}