function RuleExpression::executeWithState
Overrides ExpressionInterface::executeWithState
File
-
src/
Plugin/ RulesExpression/ RuleExpression.php, line 106
Class
- RuleExpression
- Provides a rule, executing actions when conditions are met.
Namespace
Drupal\rules\Plugin\RulesExpressionCode
public function executeWithState(ExecutionStateInterface $state) {
// Evaluate the rule's conditions.
$this->rulesDebugLogger
->info('Evaluating conditions of rule %label.', [
'%label' => $this->getLabel(),
'element' => $this,
]);
if (!$this->conditions
->isEmpty() && !$this->conditions
->executeWithState($state)) {
// Do not run the actions if the conditions are not met.
return;
}
$this->rulesDebugLogger
->info('Rule %label fires.', [
'%label' => $this->getLabel(),
'element' => $this,
'scope' => TRUE,
]);
$this->actions
->executeWithState($state);
$this->rulesDebugLogger
->info('Rule %label has fired.', [
'%label' => $this->getLabel(),
'element' => $this,
'scope' => FALSE,
]);
}