You are here

function bat_type_load_multiple 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_load_multiple()

Loads multiple Bat Types based on certain conditions.

Parameters

array $type_ids: An array of type IDs.

array $conditions: An array of conditions to match against the {bat_types} table.

bool $reset: A boolean indicating that the internal cache should be reset.

Return value

array An array of type objects, indexed by type_id.

See also

bat_type_load()

1 call to bat_type_load_multiple()
TypeBundleDeleteConfirm::buildForm in modules/bat_unit/src/Form/TypeBundleDeleteConfirm.php
Form constructor.

File

modules/bat_unit/bat_unit.module, line 636
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_load_multiple($type_ids = [], $conditions = [], $reset = FALSE) {
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('bat_unit_type')
      ->resetCache();
  }
  if (!empty($conditions)) {
    $query = \Drupal::entityQuery('bat_unit_type');
    if (!empty($type_ids)) {
      $query
        ->condition('id', $type_ids, 'IN');
    }
    foreach ($conditions as $key => $value) {
      $query
        ->condition($key, $value);
    }
    $type_ids = $query
      ->execute();
  }
  return UnitType::loadMultiple($type_ids);
}