You are here

public function Variable::evaluate in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Entity/Variable.php \Drupal\business_rules\Entity\Variable::evaluate()

Evaluate the variable.

Parameters

\Drupal\business_rules\Events\BusinessRulesEvent $event: The dispatched event.

Return value

\Drupal\business_rules\VariableObject|\Drupal\business_rules\VariablesSet The evaluated variables.

Throws

\ReflectionException

Overrides VariableInterface::evaluate

File

src/Entity/Variable.php, line 75

Class

Variable
Defines the Variable entity.

Namespace

Drupal\business_rules\Entity

Code

public function evaluate(BusinessRulesEvent $event) {
  $variable_type = $this->itemManager
    ->getDefinition($this
    ->getType());
  $reflection = new \ReflectionClass($variable_type['class']);

  /** @var \Drupal\business_rules\Plugin\BusinessRulesVariablePluginInterface $defined_variable */
  $defined_variable = $reflection
    ->newInstance($variable_type, $variable_type['id'], $variable_type);
  $variable = Variable::load($this
    ->id());
  $defined_variable
    ->processTokens($variable, $event);
  return $defined_variable
    ->evaluate($variable, $event);
}