acl->check('Calendar')) { throw new Forbidden(); } $from = $request->getQueryParam('from'); $to = $request->getQueryParam('to'); if (empty($from) || empty($to)) { throw new BadRequest(); } if (strtotime($to) - strtotime($from) > self::MAX_CALENDAR_RANGE * 24 * 3600) { throw new Forbidden('Too long range.'); } $scopeList = null; if ($request->getQueryParam('scopeList') !== null) { $scopeList = explode(',', $request->getQueryParam('scopeList')); } $userId = $request->getQueryParam('userId'); $userIdList = $request->getQueryParam('userIdList'); $userIdList = $userIdList ? explode(',', $userIdList) : []; if ($userId) { $userIdList[] = $userId; } $fetchParams = FetchParams ::create( DateTime::fromString($from . ':00'), DateTime::fromString($to . ':00') ) ->withScopeList($scopeList); $map = $this->calendarService->fetchTimelineForUsers($userIdList, $fetchParams); $result = (object) []; foreach ($map as $userId => $itemList) { $result->$userId = self::itemListToRaw($itemList); } return ResponseComposer::json($result); } /** * @param CalendarItem[] $itemList * @return stdClass[] */ private static function itemListToRaw(array $itemList): array { return array_map(fn (CalendarItem $item) => $item->getRaw(), $itemList); } }