You are here

public function RulesConditionalElement::getPreviousSibling in Conditional Rules 8

Same name and namespace in other branches
  1. 7 includes/rules_conditional.core.inc \RulesConditionalElement::getPreviousSibling()

Gets the previous sibling element.

Return value

RulesPlugin

5 calls to RulesConditionalElement::getPreviousSibling()
RulesConditionalCase::canEvaluate in includes/rules_conditional.plugin.inc
Determines whether this branch can be evaluated.
RulesConditionalDefaultCase::canEvaluate in includes/rules_conditional.plugin.inc
Determines whether this branch can be evaluated.
RulesConditionalElement::checkSiblings in includes/rules_conditional.core.inc
Checks basic conditional element integrity.
RulesConditionalIf::exportPredicate in includes/rules_conditional.plugin.inc
Exports predicate.
RulesConditionalIf::pluginLabel in includes/rules_conditional.plugin.inc

File

includes/rules_conditional.core.inc, line 266
Conditional Rules framework implementation.

Class

RulesConditionalElement
Base conditional element plugin implementation.

Code

public function getPreviousSibling() {
  if (isset($this->parent) && method_exists($this->parent, 'getIterator')) {
    $previous = NULL;
    foreach ($this->parent
      ->getIterator() as $element) {
      if ($element === $this) {
        return $previous;
      }
      $previous = $element;
    }
  }

  // Otherwise, return nothing if no previous sibling is applicable.
  return NULL;
}