You are here

class RulesConditionalWhile in Conditional Rules 8

Same name and namespace in other branches
  1. 7 includes/rules_conditional.plugin.inc \RulesConditionalWhile

While loop.

Hierarchy

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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesConditionalElement::$parent protected property The parent conditional.
RulesConditionalElement::checkSiblings protected function Checks basic conditional element integrity.
RulesConditionalElement::exportSettings protected function
RulesConditionalElement::getAllSibling public function Gets sibling elements.
RulesConditionalElement::getNextSibling public function Gets the next sibling element.
RulesConditionalElement::getPreviousSibling public function Gets the previous sibling element.
RulesConditionalElement::isDefault public function Determines whether this branch is default, i.e. covers the remainder of conditions outside of all non-default branches inside the conditional. 3
RulesConditionalElement::setParent public function @todo Remove once http://drupal.org/node/1671344 is resolved.
RulesConditionalPredicateElement::$predicate protected property
RulesConditionalPredicateElement::canEvaluate public function Evaluates the predicate. Overrides RulesConditionalElement::canEvaluate
RulesConditionalPredicateElement::dependencies public function Overrides RulesConditionalElement::dependencies
RulesConditionalPredicateElement::exportChildren protected function Exports predicate with actions. Overrides RulesConditionalElement::exportChildren
RulesConditionalPredicateElement::exportFlat protected function
RulesConditionalPredicateElement::exportPredicate protected function Exports predicate. 1
RulesConditionalPredicateElement::importChildren protected function Imports predicate. Overrides RulesConditionalElement::importChildren
RulesConditionalPredicateElement::importPredicate protected function Imports predicate. 1
RulesConditionalPredicateElement::integrityCheck public function Overrides RulesConditionalElement::integrityCheck
RulesConditionalPredicateElement::isNegated public function Returns whether the predicate is negated.
RulesConditionalPredicateElement::label public function Overrides RulesConditionalElement::label
RulesConditionalPredicateElement::negate public function Negates the predicate.
RulesConditionalPredicateElement::pluginLabel public function 1
RulesConditionalPredicateElement::resetInternalCache public function
RulesConditionalPredicateElement::setPredicate protected function Sets a condition as predicate.
RulesConditionalPredicateElement::stateVariables protected function Adds predicate assertions to state.
RulesConditionalPredicateElement::__clone public function
RulesConditionalPredicateElement::__construct public function
RulesConditionalPredicateElement::__sleep public function
RulesConditionalWhile::$itemName protected property
RulesConditionalWhile::delete public function Deletes the element and its children. Overrides RulesConditionalElement::delete
RulesConditionalWhile::evaluate public function
RulesConditionalWhile::providesVariables public function Overrides RulesConditionalElement::providesVariables