public function Event::batStoreSave in Booking and Availability Management Tools for Drupal 8
Handles saving to the BatStore
Parameters
\Roomify\Bat\Unit\Unit $unit - The unit to save:
\DateTime $start_date:
\DateTime $end_date:
$event_type:
$granularity:
$event_state:
$event_id:
bool|FALSE $remove - set to TRUE if the event is to be removed (event_id set to zero):
2 calls to Event::batStoreSave()
- Event::delete in modules/
bat_event/ src/ Entity/ Event.php - Deletes an entity permanently.
- Event::save in modules/
bat_event/ src/ Entity/ Event.php - Saves an entity permanently.
File
- modules/
bat_event/ src/ Entity/ Event.php, line 382 - Contains \Drupal\bat_event\Entity\Event.
Class
- Event
- Defines the Event entity.
Namespace
Drupal\bat_event\EntityCode
public function batStoreSave(Unit $unit, \DateTime $start_date, \DateTime $end_date, $event_type, $granularity, $event_state, $event_id, $remove = FALSE) {
$database = Database::getConnectionInfo('default');
$prefix = isset($database['default']['prefix']['default']) ? $database['default']['prefix']['default'] : '';
$state_store = new DrupalDBStore($event_type, DrupalDBStore::BAT_STATE, $prefix);
$event_store = new DrupalDBStore($event_type, DrupalDBStore::BAT_EVENT, $prefix);
$units = [
$unit,
];
$state_calendar = new Calendar($units, $state_store);
$event_calendar = new Calendar($units, $event_store);
$state_event = new BatEvent($start_date, $end_date, $unit, $event_state);
if (!$remove) {
$event_id_event = new BatEvent($start_date, $end_date, $unit, $event_id);
}
else {
$event_id_event = new BatEvent($start_date, $end_date, $unit, 0);
}
$state_calendar
->addEvents([
$state_event,
], $granularity);
$event_calendar
->addEvents([
$event_id_event,
], $granularity);
}