You are here

private static function ActionSet::checkInnerAction in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/BusinessRulesAction/ActionSet.php \Drupal\business_rules\Plugin\BusinessRulesAction\ActionSet::checkInnerAction()

Do not show actionSets that already contains the main_action.

Important to avoid infinite action check loops.

Parameters

\Drupal\business_rules\ActionInterface $main_action: The main action.

\Drupal\business_rules\ActionInterface $child_action: The child action.

Return value

bool I check succeed or fails.

1 call to ActionSet::checkInnerAction()
ActionSet::getAvailableItems in src/Plugin/BusinessRulesAction/ActionSet.php
Return all others actions with the same target Entity and Bundle.

File

src/Plugin/BusinessRulesAction/ActionSet.php, line 91

Class

ActionSet
Class ActionSet.

Namespace

Drupal\business_rules\Plugin\BusinessRulesAction

Code

private static function checkInnerAction(ActionInterface $main_action, ActionInterface $child_action) {
  $check = TRUE;
  if ($child_action
    ->getType() == 'action_set') {
    $actions = $child_action
      ->getSettings();
    foreach ($actions as $action) {
      $action = Action::load($action['action']);
      if ($main_action
        ->id() == $action
        ->id()) {
        $check = FALSE;
        break;
      }
      elseif ($action
        ->getType() == 'action_set') {
        $inner_actions = $action
          ->getSettings();
        foreach ($inner_actions as $inner_action) {
          $inner_action = Action::load($inner_action['action']);
          $check = self::checkInnerAction($action, $inner_action);
        }
      }
    }
  }
  return $check;
}