getUser($request), $user)) { throw new AuthorizationFailedException(); } $institutes = $user->institute_memberships; if (!$GLOBALS['perm']->have_profile_perm('user', $user->id)) { $institutes = $institutes->filter(fn($membership) => $membership->inst_perms !== 'user'); } $total = count($institutes); list($offset, $limit) = $this->getOffsetAndLimit(); return $this->getPaginatedContentResponse($institutes->limit($offset, $limit), $total); } }