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 ] ); } 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 ); } private function _getCalendarsForEvents(array $events) { return Calendar::finder()->findAllByPks( array_map( function($event) { return $event->CalendarID; }, $events ) ); } } ?>