function OrExpression::evaluate
Overrides ConditionExpressionContainer::evaluate
File
-
src/
Plugin/ RulesExpression/ OrExpression.php, line 21
Class
- OrExpression
- Evaluates a group of conditions with a logical OR.
Namespace
Drupal\rules\Plugin\RulesExpressionCode
public function evaluate(ExecutionStateInterface $state) {
// Use the iterator to ensure the conditions are sorted.
foreach ($this as $condition) {
/** @var \Drupal\rules\Engine\ExpressionInterface $condition */
if ($condition->executeWithState($state)) {
$this->rulesDebugLogger
->info('%label evaluated to %result.', [
'%label' => $this->getLabel(),
'%result' => 'TRUE',
]);
return TRUE;
}
}
$this->rulesDebugLogger
->info('%label evaluated to %result.', [
'%label' => $this->getLabel(),
'%result' => 'FALSE',
]);
// An empty OR should return TRUE. Otherwise, if all conditions evaluate
// to FALSE we return FALSE.
return empty($this->conditions);
}