getUser($request); if (!CourseAuthority::canShowCourse($user, $course, CourseAuthority::SCOPE_EXTENDED)) { throw new AuthorizationFailedException(); } $all_dates = array_merge( $course->dates->getArrayCopy(), $course->ex_dates->getArrayCopy() ); usort($all_dates, function ($date1, $date2) { return intval($date1->date) <=> intval($date2->date); }); list($offset, $limit) = $this->getOffsetAndLimit(); return $this->getPaginatedContentResponse(array_slice($all_dates, $offset, $limit), count($all_dates)); } }