You are here

public function BusinessRulesProcessor::executeAction in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Util/BusinessRulesProcessor.php \Drupal\business_rules\Util\BusinessRulesProcessor::executeAction()

Executes one Action.

Parameters

\Drupal\business_rules\Entity\Action $action: The action.

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

Return value

array Render array to display action result on debug block.

Throws

\ReflectionException

1 call to BusinessRulesProcessor::executeAction()
BusinessRulesProcessor::processItems in src/Util/BusinessRulesProcessor.php
Process the items.

File

src/Util/BusinessRulesProcessor.php, line 495

Class

BusinessRulesProcessor
Class BusinessRulesProcessor.

Namespace

Drupal\business_rules\Util

Code

public function executeAction(Action $action, BusinessRulesEvent $event) {

  // Dispatch a event before execute an action.
  $this->eventDispatcher
    ->dispatch('business_rules.before_execute_action', new Event($event, $action));
  $action_variables = $action
    ->getVariables();
  $this
    ->evaluateVariables($action_variables, $event);
  $result = $action
    ->execute($event);
  $this->debugArray['action_result'][$this->ruleBeingExecuted
    ->id()][$action
    ->id()] = $result;

  // Dispatch a event after execute an action.
  $this->eventDispatcher
    ->dispatch('business_rules.after_execute_action', new Event($event, $action));
  return $result;
}