public function RulesConditionalWhile::evaluate in Conditional Rules 7
Same name and namespace in other branches
- 8 includes/rules_conditional.plugin.inc \RulesConditionalWhile::evaluate()
Evaluate, whereas by default new vars are visible in the parent's scope.
Overrides RulesActionContainer::evaluate
File
- includes/
rules_conditional.plugin.inc, line 431 - Rules plugin implementation.
Class
- RulesConditionalWhile
- While loop.
Code
public function evaluate(RulesState $state) {
$iteration = 0;
$maxIterations = variable_get('rules_conditional_max_iterations', RULES_CONDITIONAL_MAX_ITERATIONS);
while ($iteration < $maxIterations && $this
->canEvaluate($state)) {
// Use a separate state so variables are available in the loop only.
$clonedState = clone $state;
parent::evaluate($clonedState);
$iteration++;
// Retrieve variables.
foreach ($state->variables as $key => &$value) {
if (array_key_exists($key, $clonedState->variables)) {
$value = $clonedState->variables[$key];
}
}
}
}