You are here

private static function ConditionSet::checkInnerCondition in Business Rules 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/BusinessRulesCondition/ConditionSet.php \Drupal\business_rules\Plugin\BusinessRulesCondition\ConditionSet::checkInnerCondition()

Do not show conditionSets that already contains the main_condition.

Important to avoid infinite condition check loops.

Parameters

\Drupal\business_rules\ConditionInterface $main_condition: The main condition.

\Drupal\business_rules\ConditionInterface $child_condition: The child condition.

Return value

bool If check succeed or fails.

1 call to ConditionSet::checkInnerCondition()
ConditionSet::getAvailableItems in src/Plugin/BusinessRulesCondition/ConditionSet.php
Return all others conditions with the same target Entity and Bundle.

File

src/Plugin/BusinessRulesCondition/ConditionSet.php, line 76

Class

ConditionSet
Class ConditionSet.

Namespace

Drupal\business_rules\Plugin\BusinessRulesCondition

Code

private static function checkInnerCondition(ConditionInterface $main_condition, ConditionInterface $child_condition) {
  $check = TRUE;
  if ($child_condition
    ->getType() == 'condition_set') {
    $conditions = $child_condition
      ->getSettings();
    foreach ($conditions as $condition) {
      $condition = Condition::load($condition['condition']);
      if ($main_condition
        ->id() == $condition
        ->id()) {
        $check = FALSE;
        break;
      }
      elseif ($condition
        ->getType() == 'condition_set') {
        $inner_conditions = $condition
          ->getSettings();
        foreach ($inner_conditions as $inner_condition) {
          $inner_condition = Condition::load($inner_condition['condition']);
          $check = self::checkInnerCondition($condition, $inner_condition);
        }
      }
    }
  }
  return $check;
}