You are here

public function Condition::getMaxItemWeight in Business Rules 8

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

Get the current max item weight.

Parameters

bool $success:

  • TRUE for items for condition succeed.
  • FALSE for items for condition fails.

Return value

int The current max item weight.

Overrides ConditionInterface::getMaxItemWeight

File

src/Entity/Condition.php, line 179

Class

Condition
Defines the Condition entity.

Namespace

Drupal\business_rules\Entity

Code

public function getMaxItemWeight($success = TRUE) {
  if ($success) {
    $items = $this->success_items;
  }
  else {
    $items = $this->fail_items;
  }
  $max = -10;
  if (is_array($items)) {
    foreach ($items as $item) {
      if ($max < $item['weight']) {
        $max = $item['weight'];
      }
    }
  }
  return $max;
}