You are here

class RulesConditionalIf in Conditional Rules 8

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

The "if" clause.

Hierarchy

Expanded class hierarchy of RulesConditionalIf

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

File

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

View source
class RulesConditionalIf extends RulesConditionalPredicateElement {
  protected $itemName = 'if';
  public function pluginLabel() {
    $previous = $this
      ->getPreviousSibling();
    if ($previous && $previous instanceof RulesConditionalIf) {
      return t('(Else) If', array(), array(
        'context' => 'conditional rules',
      ));
    }
    else {
      return parent::pluginLabel();
    }
  }

  /**
   * Imports predicate.
   */
  protected function importPredicate($export, $key = NULL) {
    $plugin = strtoupper($this
      ->plugin());
    $pluginInfo = $this
      ->pluginInfo();
    $keys = !empty($pluginInfo['import keys']) ? $pluginInfo['import keys'] : array(
      $plugin,
    );
    foreach ($keys as $key) {
      if (isset($export[$key])) {
        parent::importPredicate($export, $key);
        break;
      }
    }
  }

  /**
   * Exports predicate.
   */
  protected function exportPredicate($key = NULL) {
    if ($this
      ->getPreviousSibling()) {
      $key = 'ELSE IF';
    }
    return parent::exportPredicate($key);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::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::providesVariables public function 1
RulesConditionalElement::setParent public function @todo Remove once http://drupal.org/node/1671344 is resolved.
RulesConditionalIf::$itemName protected property
RulesConditionalIf::exportPredicate protected function Exports predicate. Overrides RulesConditionalPredicateElement::exportPredicate
RulesConditionalIf::importPredicate protected function Imports predicate. Overrides RulesConditionalPredicateElement::importPredicate
RulesConditionalIf::pluginLabel public function Overrides RulesConditionalPredicateElement::pluginLabel
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::importChildren protected function Imports predicate. Overrides RulesConditionalElement::importChildren
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::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