You are here

public function ConditionSetController::getMaxItemWeight in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Controller/ConditionSetController.php \Drupal\business_rules\Controller\ConditionSetController::getMaxItemWeight()

Get the bigger weight for the condition items.

Parameters

\Drupal\business_rules\ConditionInterface $condition: The condition to get the bigger item weight.

Return value

int The bigger weight for the condition items.

1 call to ConditionSetController::getMaxItemWeight()
ConditionSetController::addItem in src/Controller/ConditionSetController.php
Add item on Condition.

File

src/Controller/ConditionSetController.php, line 143

Class

ConditionSetController
Class ConditionSetController.

Namespace

Drupal\business_rules\Controller

Code

public function getMaxItemWeight(ConditionInterface $condition) {
  $items = $condition
    ->getSettings('items');
  $max = -100;
  if (is_array($items)) {
    foreach ($items as $item) {
      if ($max < $item['weight']) {
        $max = $item['weight'];
      }
    }
  }
  return $max;
}