You are here

class RulesConditionalDefaultCase in Conditional Rules 8

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

Switch default case.

Hierarchy

Expanded class hierarchy of RulesConditionalDefaultCase

1 string reference to 'RulesConditionalDefaultCase'
rules_conditional_rules_plugin_info in ./rules_conditional.rules.inc
Implements hook_rules_plugin_info().

File

includes/rules_conditional.plugin.inc, line 378
Rules plugin implementation.

View source
class RulesConditionalDefaultCase extends RulesConditionalElement {
  protected $itemName = 'default case';
  public function __construct() {
    parent::__construct();
  }
  public function canEvaluate(RulesState $state) {

    // Check if this element has fallen through.
    if ($previous = $this
      ->getPreviousSibling()) {

      /** @var $previous self */
      if ($previous
        ->fallThrough() && $previous
        ->canEvaluate($state)) {
        return $this
          ->isDefault();
      }
    }
    $siblings = $this
      ->getAllSibling();
    $sibling_can_evaluate = FALSE;
    foreach ($siblings as $sibling) {
      if ($sibling
        ->canEvaluate($state)) {
        $sibling_can_evaluate = TRUE;
      }
    }
    return $sibling_can_evaluate ? FALSE : $this
      ->isDefault();
  }
  public function isDefault() {
    return TRUE;
  }
  protected function importChildren($export, $key = NULL) {
    RulesContainerPlugin::importChildren($export);
  }
  protected function exportChildren($key = NULL) {
    return RulesContainerPlugin::exportChildren();
  }
  protected function exportFlat() {
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesConditionalDefaultCase::$itemName protected property
RulesConditionalDefaultCase::canEvaluate public function Determines whether this branch can be evaluated. Overrides RulesConditionalElement::canEvaluate
RulesConditionalDefaultCase::exportChildren protected function Overrides RulesConditionalElement::exportChildren
RulesConditionalDefaultCase::exportFlat protected function
RulesConditionalDefaultCase::importChildren protected function Overrides RulesConditionalElement::importChildren
RulesConditionalDefaultCase::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. Overrides RulesConditionalElement::isDefault
RulesConditionalDefaultCase::__construct public function
RulesConditionalElement::$parent protected property The parent conditional.
RulesConditionalElement::checkSiblings protected function Checks basic conditional element integrity.
RulesConditionalElement::delete public function Deletes the element and its children. 1
RulesConditionalElement::dependencies public function 1
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::integrityCheck public function 1
RulesConditionalElement::label public function 1
RulesConditionalElement::providesVariables public function 1
RulesConditionalElement::setParent public function @todo Remove once http://drupal.org/node/1671344 is resolved.