calendarManager->newQuery('principals/users/' . $userId); if ($location !== null) { $searchQuery->addSearchProperty('LOCATION'); $searchQuery->setSearchPattern($location); } $searchQuery->addType('VEVENT'); $searchQuery->setLimit(3); $now = $this->timeFactory->now(); $searchQuery->setTimerangeStart($now->modify('-1 minute')); $searchQuery->setTimerangeEnd($now->modify('+1 month')); $events = $this->calendarManager->searchForPrincipal($searchQuery); $calendarAppEnabled = $this->appManager->isEnabledForUser( 'calendar', $this->userManager->get($userId), ); return array_map(fn (array $event) => new UpcomingEvent( $event['uri'], ($event['objects'][0]['RECURRENCE-ID'][0] ?? null)?->getTimeStamp(), $event['calendar-uri'], $event['objects'][0]['DTSTART'][0]?->getTimestamp(), $event['objects'][0]['SUMMARY'][0] ?? null, $event['objects'][0]['LOCATION'][0] ?? null, match ($calendarAppEnabled) { // TODO: create a named, deep route in calendar // TODO: it's a code smell to just assume this route exists, find an abstraction true => $this->urlGenerator->linkToRouteAbsolute('calendar.view.index'), false => null, }, ), $events); } }