public function RulesConditionalDefaultCase::canEvaluate in Conditional Rules 7
Same name and namespace in other branches
- 8 includes/rules_conditional.plugin.inc \RulesConditionalDefaultCase::canEvaluate()
Determines whether this branch can be evaluated.
Non-default plugins should override this method.
Overrides RulesConditionalElement::canEvaluate
File
- includes/
rules_conditional.plugin.inc, line 385 - Rules plugin implementation.
Class
- RulesConditionalDefaultCase
- Switch default case.
Code
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();
}