public function RuleExpression::executeWithState in Rules 8.3
Execute the expression with a given Rules state.
Note that this does not auto-save any changes.
Parameters
\Drupal\rules\Context\ExecutionStateInterface $state: The state with all the execution variables in it.
Return value
null|bool The expression may return a boolean value after execution, this is used by conditions that return their evaluation result.
Throws
\Drupal\rules\Exception\EvaluationException Thrown if the Rules expression triggers errors during execution.
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,
]);
}