summaryrefslogtreecommitdiff
path: root/app/php/facades
diff options
context:
space:
mode:
Diffstat (limited to 'app/php/facades')
-rw-r--r--app/php/facades/EventFacade.php35
1 files changed, 22 insertions, 13 deletions
diff --git a/app/php/facades/EventFacade.php b/app/php/facades/EventFacade.php
index 6c51716..32dab88 100644
--- a/app/php/facades/EventFacade.php
+++ b/app/php/facades/EventFacade.php
@@ -2,8 +2,7 @@
Prado::using('Application.facades.Facade');
Prado::using('Application.dto.EventDTO');
-Prado::using('Application.dto.GridEventDTO');
-Prado::using('Application.dto.CalendarGridDTO');
+Prado::using('Application.dto.TimezoneDTO');
Prado::using('Application.model.Calendar');
Prado::using('Application.facades.CalendarFacade');
Prado::using('Application.user.DbUser');
@@ -38,9 +37,23 @@ class EventFacade extends Facade {
);
}
- public function getTimeframeListForUser(DbUser $user,
- DateTime $dateFrom,
- DateTime $dateTo) {
+ private function _compileEventObjects(array $events, array $calendars,
+ TimezoneDTO $tz,
+ string $class = 'Application.dto.EventDTO') {
+ return array_map(
+ function($event) use($calendars, $class, $tz) {
+ $dto = Prado::createComponent($class, $tz);
+ $dto->loadRecord($event, $calendars);
+ return $dto;
+ },
+ $events
+ );
+ }
+
+ public function getTimeframeListForUser(
+ DbUser $user,
+ DateTime $dateFrom, DateTime $dateTo,
+ string $returnClass = 'Application.dto.EventDTO') {
$calendars = CalendarFacade::getInstance()->getCalendarPreference($user);
if ($calendars) {
$events = $this->getEventList(
@@ -49,14 +62,10 @@ class EventFacade extends Facade {
$calendars
);
$calendars = $this->_getCalendarsForEvents($events);
- return array_map(
- function($event) use($calendars) {
- $dto = new EventDTO();
- $dto->loadRecord($event, $calendars);
- return $dto;
- },
- $events
- );
+ return $this->_compileEventObjects(
+ $events, $calendars,
+ UserFacade::getInstance()->getTimezonePreference($user),
+ $returnClass);
}
return [];
}