public function ConditionExpression::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/ ConditionExpression.php, line 114
Class
- ConditionExpression
- Defines an executable condition expression.
Namespace
Drupal\rules\Plugin\RulesExpressionCode
public function executeWithState(ExecutionStateInterface $state) {
$condition = $this->conditionManager
->createInstance($this->configuration['condition_id'], [
'negate' => $this->configuration['negate'],
]);
$this
->prepareContext($condition, $state);
$result = $condition
->evaluate();
if ($this
->isNegated()) {
$result = !$result;
}
$this->rulesDebugLogger
->info('The condition %name evaluated to %bool.', [
'%name' => $this
->getLabel(),
'%bool' => $result ? 'TRUE' : 'FALSE',
'element' => $this,
]);
// Now that the condition has been executed it can provide additional
// context which we will have to pass back in the evaluation state.
$this
->addProvidedContext($condition, $state);
return $result;
}