function bat_unit_load_multiple in Booking and Availability Management Tools for Drupal 8
Same name and namespace in other branches
- 7 modules/bat_unit/bat_unit.module \bat_unit_load_multiple()
Loads multiple units based on certain conditions.
Parameters
array $unit_ids: An array of unit IDs.
array $conditions: An array of conditions to match against the {unit} table.
bool $reset: A boolean indicating that the internal cache should be reset.
Return value
array An array of unit objects, indexed by unit_id.
See also
5 calls to bat_unit_load_multiple()
- BatEventUiBulkUpdateForm::submitForm in modules/
bat_event_ui/ src/ Form/ BatEventUiBulkUpdateForm.php - Form submission handler.
- bat_event_get_calendar in modules/
bat_event/ bat_event.module - Retrieves relevant units and instantiates a BAT calendar object than can be reused. It is preferred to use this function to reduce the cost of setting up a calendar (i.e. loading units).
- bat_facets_search_api_query_alter in modules/
bat_facets/ bat_facets.module - Implements hook_search_api_query_alter().
- bat_unit_entity_delete in modules/
bat_unit/ bat_unit.module - Implements hook_entity_delete().
- BookingConfirmationForm::submitForm in modules/
bat_booking/ bat_booking_example/ src/ Form/ BookingConfirmationForm.php - Form submission handler.
File
- modules/
bat_unit/ bat_unit.module, line 327 - 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_unit_load_multiple($unit_ids = [], $conditions = [], $reset = FALSE) {
if ($reset) {
\Drupal::entityTypeManager()
->getStorage('bat_unit')
->resetCache();
}
if (!empty($conditions)) {
$query = \Drupal::entityQuery('bat_unit');
if (!empty($unit_ids)) {
$query
->condition('id', $unit_ids, 'IN');
}
foreach ($conditions as $key => $value) {
$query
->condition($key, $value);
}
$unit_ids = $query
->execute();
}
return Unit::loadMultiple($unit_ids);
}