You are here

public static function BusinessRulesItemObject::itemsArrayToItemsObject in Business Rules 8

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

Transform the items array in a array of BusinessRulesItemObject.

Parameters

array $items: The items array.

Return value

array Array of BusinessRulesItemObject.

11 calls to BusinessRulesItemObject::itemsArrayToItemsObject()
Action::calculateDependencies in src/Entity/Action.php
Calculates dependencies and stores them in the dependency property.
ActionSet::execute in src/Plugin/BusinessRulesAction/ActionSet.php
Execute the action.
BusinessRule::getItems in src/Entity/BusinessRule.php
The Business rule's items.
Condition::calculateDependencies in src/Entity/Condition.php
Calculates dependencies and stores them in the dependency property.
Condition::getFailItems in src/Entity/Condition.php
Get all condition's fail items.

... See full list

File

src/BusinessRulesItemObject.php, line 66

Class

BusinessRulesItemObject
Class BusinessRulesItemObject.

Namespace

Drupal\business_rules

Code

public static function itemsArrayToItemsObject(array $items) {
  $obj_items = [];
  if (is_array($items)) {
    uasort($items, function ($a, $b) {
      return $a['weight'] < $b['weight'] ? -1 : 1;
    });
    foreach ($items as $item) {
      $itemObj = new BusinessRulesItemObject($item['id'], $item['type'], $item['weight']);
      $obj_items[$item['id']] = $itemObj;
    }
  }
  return $obj_items;
}