quoteString($calendar->UID); }, $calendars ) ) ); } return $this->fetchList( 'getEvents', [ 'date_from' => $dateFrom ?: '0000-00-00 00:00:00', 'date_to' => $dateTo ?: '9999-99-99', 'calendar_clause' => $calendarClause, 'order_clause' => $order ] ); } 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( $dateFrom->format('Y-m-d H:i:s'), $dateTo->format('Y-m-d H:i:s'), $calendars ); $calendars = $this->_getCalendarsForEvents($events); return $this->_compileEventObjects( $events, $calendars, UserFacade::getInstance()->getTimezonePreference($user), $returnClass); } return []; } private function _getCalendarsForEvents(array $events) { if ($events) { return Calendar::finder()->findAllByPks( array_map( function($event) { return $event->CalendarID; }, $events ) ); } return []; } } ?>