function bat_event_get_calendar in Booking and Availability Management Tools for Drupal 7
Same name and namespace in other branches
- 8 modules/bat_event/bat_event.module \bat_event_get_calendar()
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).
Parameters
$type_id:
$event_type:
Return value
Roomify\Bat\Calendar\Calendar
2 calls to bat_event_get_calendar()
- bat_event_get_calendar_response in modules/
bat_event/ bat_event.module - Given a date range and a set of valid states it will return all units within the set of valid states.
- bat_event_get_matching_units in modules/
bat_event/ bat_event.module - Given a date range and a set of valid states it will return all units within the set of valid states.
File
- modules/
bat_event/ bat_event.module, line 2421 - Manage Events - Events store the EventValue of a Unit over a period of time.
Code
function bat_event_get_calendar($type_id, $event_type) {
$state_store = new DrupalDBStore($event_type, DrupalDBStore::BAT_STATE, bat_get_db_prefix());
$drupal_units = bat_unit_load_multiple(FALSE, array(
'type_id' => $type_id,
));
$bat_units = array();
foreach ($drupal_units as $unit_id => $unit) {
$bat_units[] = new Unit($unit_id, $unit
->getEventDefaultValue($event_type));
}
$calendar = new Calendar($bat_units, $state_store);
return $calendar;
}