You are here

function bat_type_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_ids()

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

1 call to bat_type_ids()
bat_facets_search_api_query_alter in modules/bat_facets/bat_facets.module
Implements hook_search_api_query_alter().

File

modules/bat_unit/bat_unit.module, line 739
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_ids($bundle = NULL) {
  $types = [];
  $query = \Drupal::entityQuery('bat_unit_type');
  if ($bundle !== NULL) {
    $query
      ->condition('type', $bundle);
  }
  $result = $query
    ->execute();
  if (count($result) > 0) {
    $entities = UnitType::loadMultiple(array_keys($result));
    foreach ($entities as $type) {
      $types[$type
        ->id()] = $type
        ->label();
    }
  }
  return $types;
}