You are here

public function BusinessRulesItemBase::getTypes in Business Rules 8

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

Get all item types available.

Return value

array All item types available

Overrides ItemInterface::getTypes

1 call to BusinessRulesItemBase::getTypes()
BusinessRulesItemBase::getTypeLabel in src/Entity/BusinessRulesItemBase.php
Get the readable Type label.

File

src/Entity/BusinessRulesItemBase.php, line 235

Class

BusinessRulesItemBase
Class Item.

Namespace

Drupal\business_rules\Entity

Code

public function getTypes() {
  $types = [];
  $items = $this->itemManager
    ->getDefinitions();
  uasort($items, function ($a, $b) {
    return $a['label']
      ->render() > $b['label']
      ->render() ? 1 : -1;
  });
  foreach ($items as $item) {
    if (isset($types[$item['group']
      ->render()])) {
      $types[$item['group']
        ->render()] += [
        $item['id'] => $item['label'],
      ];
    }
    else {
      $types[$item['group']
        ->render()] = [
        $item['id'] => $item['label'],
      ];
    }
  }
  ksort($types);
  return $types;
}