You are here

function bat_booking_load_multiple in Booking and Availability Management Tools for Drupal 8

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

Loads multiple bookings based on certain conditions.

Parameters

array $booking_ids: An array of booking IDs.

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

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

Return value

array An array of booking objects, indexed by booking_id.

See also

bat_booking_load()

2 calls to bat_booking_load_multiple()
bat_booking_load in modules/bat_booking/bat_booking.module
Fetches a booking object.
BookingBundleDeleteConfirm::buildForm in modules/bat_booking/src/Form/BookingBundleDeleteConfirm.php
Form constructor.

File

modules/bat_booking/bat_booking.module, line 143

Code

function bat_booking_load_multiple($booking_ids = [], $conditions = [], $reset = FALSE) {
  if ($reset) {
    \Drupal::entityTypeManager()
      ->getStorage('bat_booking')
      ->resetCache();
  }
  if (!empty($conditions)) {
    $query = \Drupal::entityQuery('bat_booking');
    if (!empty($booking_ids)) {
      $query
        ->condition('id', $booking_ids, 'IN');
    }
    foreach ($conditions as $key => $value) {
      $query
        ->condition($key, $value);
    }
    $booking_ids = $query
      ->execute();
  }
  return Booking::loadMultiple($booking_ids);
}