You are here

public function RulesComponent::execute in Rules 8.3

Executes the component with the previously set context.

Return value

mixed[] The array of provided context values, keyed by context name.

Throws

\Drupal\rules\Exception\EvaluationException Thrown if the Rules expression triggers errors during execution.

1 call to RulesComponent::execute()
RulesComponent::executeWithArguments in src/Engine/RulesComponent.php
Executes the component with the given values.

File

src/Engine/RulesComponent.php, line 235

Class

RulesComponent
Handles executable Rules components.

Namespace

Drupal\rules\Engine

Code

public function execute() {

  // @todo Use injection for the service.
  $rulesDebugLogger = \Drupal::service('logger.channel.rules_debug');
  $rulesDebugLogger
    ->info('RulesComponent: Rule %label fires.', [
    '%label' => $this->expression
      ->getLabel(),
    'element' => $this->expression,
    'scope' => TRUE,
  ]);
  $this->expression
    ->executeWithState($this->state);
  $rulesDebugLogger
    ->info('RulesComponent: Rule %label has fired.', [
    '%label' => $this->expression
      ->getLabel(),
    'element' => $this->expression,
    'scope' => FALSE,
  ]);
  $this->state
    ->autoSave();
  $result = [];
  foreach ($this->providedContext as $name) {
    $result[$name] = $this->state
      ->getVariableValue($name);
  }
  return $result;
}