diff options
author | emkael <emkael@tlen.pl> | 2016-05-06 15:40:50 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-06 15:40:50 +0200 |
commit | a43e887c380fc414121792658136a34051526b6a (patch) | |
tree | 1816ec713671d02dd3d24e92c2f4675f7deab30d /app/php/facades/EventFacade.php | |
parent | 5bfe174b5907440a4f08bd45fd9c384ab5c58037 (diff) |
* DbUser refactored to use a facade
Diffstat (limited to 'app/php/facades/EventFacade.php')
-rw-r--r-- | app/php/facades/EventFacade.php | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/app/php/facades/EventFacade.php b/app/php/facades/EventFacade.php index a41b2f7..9533448 100644 --- a/app/php/facades/EventFacade.php +++ b/app/php/facades/EventFacade.php @@ -3,6 +3,7 @@ Prado::using('Application.facades.Facade'); Prado::using('Application.dto.EventDTO'); Prado::using('Application.model.Calendar'); +Prado::using('Application.facades.CalendarFacade'); Prado::using('Application.user.DbUser'); class EventFacade extends Facade { @@ -37,20 +38,24 @@ class EventFacade extends Facade { public function getTimeframeListForUser(DbUser $user, DateTime $dateFrom, DateTime $dateTo) { - $events = $this->getEventList( - $dateFrom->format('Y-m-d H:i:s'), - $dateTo->format('Y-m-d H:i:s'), - $user->getCalendarPreference() - ); - $calendars = $this->_getCalendarsForEvents($events); - return array_map( - function($event) use($calendars) { - $dto = new EventDTO(); - $dto->loadRecord($event, $calendars); - return $dto; - }, - $events - ); + $calendars = CalendarFacade::getInstance()->getCalendarPreference($user); + if ($calendars) { + $events = $this->getEventList( + $dateFrom->format('Y-m-d H:i:s'), + $dateTo->format('Y-m-d H:i:s'), + $calendars + ); + $calendars = $this->_getCalendarsForEvents($events); + return array_map( + function($event) use($calendars) { + $dto = new EventDTO(); + $dto->loadRecord($event, $calendars); + return $dto; + }, + $events + ); + } + return []; } private function _getCalendarsForEvents(array $events) { |