class RulesConditional in Conditional Rules 8
Same name and namespace in other branches
- 7 includes/rules_conditional.plugin.inc \RulesConditional
Default if-else conditional statement.
@method RulesConditional if() if($predicate, array $settings = array()) Adds an "if" statement. @method RulesConditional elseIf() elseIf($predicate, array $settings = array()) Adds an "else if" statement. This is an alias for self::if(). @method RulesConditional else() else() Adds an "else" statement. @method RulesConditional action() action($name, array $settings = array()) Adds an action to the currently active statement. Pass arguments as rules_action() would need.
Hierarchy
- class \RulesConditionalContainer extends \RulesContainerPlugin implements \RulesActionInterface
- class \RulesConditional
Expanded class hierarchy of RulesConditional
1 string reference to 'RulesConditional'
- rules_conditional_rules_plugin_info in ./
rules_conditional.rules.inc - Implements hook_rules_plugin_info().
File
- includes/
rules_conditional.plugin.inc, line 21 - Rules plugin implementation.
View source
class RulesConditional extends RulesConditionalContainer {
protected $itemName = 'conditional';
/**
* Intercepts calls to "if" and "else".
* @var array
*/
protected $interceptMethods = array(
'if',
'elseIf',
'else',
);
public function __construct() {
parent::__construct();
}
/**
* Adds an "if" statement, for use with magic call.
*/
protected function call_if($predicate, array $settings = array()) {
$this->fluentElement = $element = rules_conditional_if($predicate, $settings);
$element
->setParent($this);
return $this;
}
/**
* Adds an "if" as an "else if" statement, for use with magic call.
*/
protected function call_elseIf($predicate, array $settings = array()) {
return $this
->call_if($predicate, $settings);
}
/**
* Adds an "else" statement, for use with magic call.
*/
protected function call_else() {
$this->fluentElement = $element = rules_conditional_else();
$element
->setParent($this);
return $this;
}
/**
* Selects the branches to evaluate for this conditional.
*
* @param RulesState $state
* Rules state to use.
* @return RulesConditionalElement[]
* An array of branches to evaluate.
*/
protected function selectBranches(RulesState $state) {
/** @var $branch RulesConditionalElement */
foreach ($this->children as $branch) {
// Select the first matched branch.
if ($branch
->canEvaluate($state)) {
return array(
$branch,
);
}
}
// Return no branch if none matched.
return array();
}
protected function exportFlat() {
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RulesConditional:: |
protected | property |
Intercepts calls to "if" and "else". Overrides RulesConditionalContainer:: |
|
RulesConditional:: |
protected | property | ||
RulesConditional:: |
protected | function | Adds an "else" statement, for use with magic call. | |
RulesConditional:: |
protected | function | Adds an "if" as an "else if" statement, for use with magic call. | |
RulesConditional:: |
protected | function | Adds an "if" statement, for use with magic call. | |
RulesConditional:: |
protected | function | ||
RulesConditional:: |
protected | function |
Selects the branches to evaluate for this conditional. Overrides RulesConditionalContainer:: |
|
RulesConditional:: |
public | function | ||
RulesConditionalContainer:: |
protected | property | ||
RulesConditionalContainer:: |
protected | property | ||
RulesConditionalContainer:: |
public | function | Adds an action to the active fluent statement. | |
RulesConditionalContainer:: |
public | function | Deletes the container and its children. | |
RulesConditionalContainer:: |
public | function | ||
RulesConditionalContainer:: |
public | function | ||
RulesConditionalContainer:: |
public | function | Evaluates the conditional statement. | |
RulesConditionalContainer:: |
protected | function | ||
RulesConditionalContainer:: |
public | function | ||
RulesConditionalContainer:: |
public | function | Provides intersections of variables in all branches, at least one default. | |
RulesConditionalContainer:: |
public | function | ||
RulesConditionalContainer:: |
protected | function | Declares only parent state variables for individual branches. | |
RulesConditionalContainer:: |
protected | function | Asserts no variables (since a conditional is *conditionally* evaluated). | |
RulesConditionalContainer:: |
public | function | Intercepts calls to magic methods, possibly using reserved keywords. |