You are here

public static function ConditionSet::getAvailableItems 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::getAvailableItems()

Return all others conditions with the same target Entity and Bundle.

Parameters

\Drupal\business_rules\Entity\Condition $condition: The condition.

Return value

array Array of conditions matched.

1 call to ConditionSet::getAvailableItems()
ConditionSetController::init in src/Controller/ConditionSetController.php
Init properties.

File

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

Class

ConditionSet
Class ConditionSet.

Namespace

Drupal\business_rules\Plugin\BusinessRulesCondition

Code

public static function getAvailableItems(Condition $condition) {
  $conditions = Condition::loadMultiple();
  $current_conditions = $condition
    ->getSettings('items');
  $conditions_matched = [];
  if (count($conditions)) {

    /** @var \Drupal\business_rules\Entity\Condition $c */
    foreach ($conditions as $c) {
      if ($condition
        ->id() != $c
        ->id() && self::checkInnerCondition($condition, $c) && !in_array($c
        ->id(), array_keys($current_conditions))) {

        // Only condition s with no actions can be added to a condition set.
        if (!count($c
          ->getSuccessItems()) && !count($c
          ->getFailItems())) {
          $conditions_matched[] = $c;
        }
      }
    }
  }
  return $conditions_matched;
}