class RulesConditionalSwitch in Conditional Rules 8
Same name and namespace in other branches
- 7 includes/rules_conditional.plugin.inc \RulesConditionalSwitch
Switch conditional container.
@method RulesConditionalSwitch case() case($value, $fallThrough = FALSE, $valueIsSelector = FALSE) Adds a "case" statement. @method RulesConditionalSwitch defaultCase() defaultCase() Adds a "default case" statement. @method RulesConditionalSwitch 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 \RulesConditionalSwitch
Expanded class hierarchy of RulesConditionalSwitch
1 string reference to 'RulesConditionalSwitch'
- rules_conditional_rules_plugin_info in ./
rules_conditional.rules.inc - Implements hook_rules_plugin_info().
File
- includes/
rules_conditional.plugin.inc, line 160 - Rules plugin implementation.
View source
class RulesConditionalSwitch extends RulesConditionalContainer {
protected $itemName = 'switch';
/**
* Intercepts calls to "case" and "defaultCase".
* @var array
*/
protected $interceptMethods = array(
'case',
'defaultCase',
);
public function __construct($dataSelector = NULL) {
parent::__construct();
if (isset($dataSelector)) {
$this->settings['data:select'] = $dataSelector;
}
}
/**
* Adds a "case" statement, for use with magic call.
*/
protected function call_case($settings = array(), $fallThrough = FALSE) {
$this->fluentElement = $element = rules_conditional_case($settings, $fallThrough);
$element
->setParent($this);
return $this;
}
/**
* Adds a "defaultCase" statement, for use with magic call.
*/
protected function call_defaultCase() {
$this->fluentElement = $element = rules_conditional_default_case();
$element
->setParent($this);
return $this;
}
public function pluginParameterInfo() {
$parameterInfo = array(
'data' => array(
'type' => '*',
'label' => t('Data to match cases against'),
'description' => t('The data to be compared, specified by using a data selector, e.g. "node:author:name".'),
'restriction' => 'selector',
'allow null' => TRUE,
),
);
return $parameterInfo;
}
/**
* 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) {
$branches = array();
// Collect all cases to be evaluated.
$fallThrough = FALSE;
foreach ($this->children as $case) {
/** @var $case RulesConditionalCase */
if ($case
->canEvaluate($state)) {
$branches[] = $case;
}
}
return $branches;
}
protected function importChildren($export, $key = NULL) {
parent::importChildren($export, 'DO');
}
protected function exportChildren($key = NULL) {
return parent::exportChildren('DO');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
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. | |
RulesConditionalSwitch:: |
protected | property |
Intercepts calls to "case" and "defaultCase". Overrides RulesConditionalContainer:: |
|
RulesConditionalSwitch:: |
protected | property | ||
RulesConditionalSwitch:: |
protected | function | Adds a "case" statement, for use with magic call. | |
RulesConditionalSwitch:: |
protected | function | Adds a "defaultCase" statement, for use with magic call. | |
RulesConditionalSwitch:: |
protected | function | ||
RulesConditionalSwitch:: |
protected | function | ||
RulesConditionalSwitch:: |
public | function | ||
RulesConditionalSwitch:: |
protected | function |
Selects the branches to evaluate for this conditional. Overrides RulesConditionalContainer:: |
|
RulesConditionalSwitch:: |
public | function |