class RulesConditionalWhile in Conditional Rules 8
Same name and namespace in other branches
- 7 includes/rules_conditional.plugin.inc \RulesConditionalWhile
While loop.
Hierarchy
- class \RulesConditionalElement extends \RulesActionContainer implements \RulesActionInterface
- class \RulesConditionalPredicateElement
- class \RulesConditionalWhile
- class \RulesConditionalPredicateElement
Expanded class hierarchy of RulesConditionalWhile
1 string reference to 'RulesConditionalWhile'
- rules_conditional_rules_plugin_info in ./
rules_conditional.rules.inc - Implements hook_rules_plugin_info().
File
- includes/
rules_conditional.plugin.inc, line 424 - Rules plugin implementation.
View source
class RulesConditionalWhile extends RulesConditionalPredicateElement {
protected $itemName = 'while';
public function providesVariables() {
return array();
}
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];
}
}
}
}
/**
* Deletes the element and its children.
*/
public function delete($keep_children = TRUE) {
parent::delete($keep_children);
}
}