getUser($request), $membership)) { throw new AuthorizationFailedException(); } return $this->getContentResponse($membership); } private function findMembership($id) { if (!preg_match('/^([^_]+)_(.+)$/', $id, $matches)) { throw new BadRequestException(); } if (!$membership = \CourseMember::find([$matches[1], $matches[2]])) { throw new RecordNotFoundException(); } return $membership; } }