You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace BusinessLogic\Calendar;
|
|
|
|
|
|
use BusinessLogic\Security\UserContext;
|
|
use DataAccess\Calendar\CalendarGateway;
|
|
|
|
class CalendarHandler extends \BaseClass {
|
|
private $calendarGateway;
|
|
|
|
public function __construct(CalendarGateway $calendarGateway) {
|
|
$this->calendarGateway = $calendarGateway;
|
|
}
|
|
|
|
public function getEventsForStaff($searchEventsFilter, $heskSettings) {
|
|
return $this->calendarGateway->getEventsForStaff($searchEventsFilter, $heskSettings);
|
|
}
|
|
|
|
/**
|
|
* @param $calendarEvent CalendarEvent
|
|
* @param $userContext UserContext
|
|
* @param $heskSettings array
|
|
* @return CalendarEvent
|
|
* @throws \Exception If more than one event is returned for the given ID
|
|
*/
|
|
public function updateEvent($calendarEvent, $userContext, $heskSettings) {
|
|
$this->calendarGateway->updateEvent($calendarEvent, $userContext, $heskSettings);
|
|
|
|
$eventFilter = new SearchEventsFilter();
|
|
$eventFilter->eventId = $calendarEvent->id;
|
|
$eventFilter->reminderUserId = $userContext->id;
|
|
|
|
$events = $this->calendarGateway->getEventsForStaff($eventFilter, $heskSettings);
|
|
|
|
if (count($events) !== 1) {
|
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
|
}
|
|
|
|
return $events[0];
|
|
}
|
|
|
|
|
|
public function createEvent($calendarEvent, $userContext, $heskSettings) {
|
|
$this->calendarGateway->createEvent($calendarEvent, $userContext, $heskSettings);
|
|
|
|
$eventFilter = new SearchEventsFilter();
|
|
$eventFilter->eventId = $calendarEvent->id;
|
|
$eventFilter->reminderUserId = $userContext->id;
|
|
|
|
$events = $this->calendarGateway->getEventsForStaff($eventFilter, $heskSettings);
|
|
|
|
if (count($events) !== 1) {
|
|
throw new \Exception("Expected exactly 1 event, found: " . count($events));
|
|
}
|
|
|
|
return $events[0];
|
|
}
|
|
|
|
public function deleteEvent($id, $userContext, $heskSettings) {
|
|
$this->calendarGateway->deleteEvent($id, $userContext, $heskSettings);
|
|
}
|
|
} |