function AndExpression::evaluate
Overrides ConditionExpressionContainer::evaluate
File
-
src/
Plugin/ RulesExpression/ AndExpression.php, line 34
Class
- AndExpression
- Evaluates a group of conditions with a logical AND.
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' => 'FALSE',
]);
return FALSE;
}
}
$this->rulesDebugLogger
->info('%label evaluated to %result.', [
'%label' => $this->getLabel(),
'%result' => 'TRUE',
]);
// An empty AND should return FALSE. Otherwise, if all conditions evaluate
// to TRUE we return TRUE.
return !empty($this->conditions);
}