class RulesConditionalDefaultCase in Conditional Rules 8
Same name and namespace in other branches
- 7 includes/rules_conditional.plugin.inc \RulesConditionalDefaultCase
Switch default case.
Hierarchy
- class \RulesConditionalElement extends \RulesActionContainer implements \RulesActionInterface
- class \RulesConditionalDefaultCase
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;
}
}