public function BusinessRulesProcessor::evaluateVariables in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Util/BusinessRulesProcessor.php \Drupal\business_rules\Util\BusinessRulesProcessor::evaluateVariables()
Evaluate all variables from a VariableSet for a given event.
Parameters
\Drupal\business_rules\VariablesSet $variablesSet: The variable set.
\Drupal\business_rules\Events\BusinessRulesEvent $event: The event.
Throws
\Exception
3 calls to BusinessRulesProcessor::evaluateVariables()
- BusinessRulesProcessor::evaluateVariable in src/
Util/ BusinessRulesProcessor.php - Evaluate the variable value.
- BusinessRulesProcessor::executeAction in src/
Util/ BusinessRulesProcessor.php - Executes one Action.
- BusinessRulesProcessor::isConditionValid in src/
Util/ BusinessRulesProcessor.php - Checks if one condition is valid.
File
- src/
Util/ BusinessRulesProcessor.php, line 663
Class
- BusinessRulesProcessor
- Class BusinessRulesProcessor.
Namespace
Drupal\business_rules\UtilCode
public function evaluateVariables(VariablesSet $variablesSet, BusinessRulesEvent $event) {
// Dispatch a event before evaluate variables.
$this->eventDispatcher
->dispatch('business_rules.before_evaluate_variables', new Event($event, $variablesSet));
/** @var \Drupal\business_rules\VariableObject $variable */
/** @var \Drupal\business_rules\VariablesSet $eventVariables */
if ($variablesSet
->count()) {
foreach ($variablesSet
->getVariables() as $variable) {
$varObject = Variable::load($variable
->getId());
if ($varObject instanceof Variable) {
// Do note evaluate the same variable twice to avid overload.
if (!array_key_exists($variable
->getId(), $this->evaluatedVariables)) {
$this
->evaluateVariable($varObject, $event);
}
}
}
}
// Dispatch a event after evaluate variables.
$this->eventDispatcher
->dispatch('business_rules.after_evaluate_variables', new Event($event, $variablesSet));
}