You are here

function bat_type_bundle_ids in Booking and Availability Management Tools for Drupal 8

Same name and namespace in other branches
  1. 7 modules/bat_unit/bat_unit.module \bat_type_bundle_ids()

Gets a list of Bat Type bundles keyed by id and name in value.

File

modules/bat_unit/bat_unit.module, line 763
Manage units - Units are things that can be booked for some period of time. (e.g. rooms - but also villas bungalows, cars, drills, you-get-the-idea etc.)

Code

function bat_type_bundle_ids() {
  $type_bundles = [];
  $query = \Drupal::entityQuery('bat_type_bundle');
  $result = $query
    ->execute();
  if (count($result) > 0) {
    $entities = TypeBundle::loadMultiple(array_keys($result['bat_type_bundle']));
    foreach ($entities as $type_bundle) {
      $type_bundles[$type_bundle
        ->id()] = $type_bundle
        ->label();
    }
  }
  return $type_bundles;
}