repository = $repository; $this->service = $service; } /** * @return mixed */ public function getMyInvitations(){ try { $current_member = $this->resource_server_context->getCurrentUser(); if (is_null($current_member)) return $this->error403(); $invitations = $this->repository->getInvitationsByInvitee($current_member->getId()); $response = new PagingResponse ( count($invitations), count($invitations), 1, 1, $invitations ); return $this->ok($response->toArray($expand = Request::input('expand',''))); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @return mixed */ public function getMyPendingInvitations(){ try { $current_member = $this->resource_server_context->getCurrentUser(); if (is_null($current_member)) return $this->error403(); $invitations = $this->repository->getPendingInvitationsByInvitee($current_member->getId()); $response = new PagingResponse ( count($invitations), count($invitations), 1, 1, $invitations ); return $this->ok($response->toArray($expand = Request::input('expand',''))); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @return mixed */ public function getMyAcceptedInvitations(){ try { $current_member = $this->resource_server_context->getCurrentUser(); if (is_null($current_member)) return $this->error403(); $invitations = $this->repository->getAcceptedInvitationsByInvitee($current_member->getId()); $response = new PagingResponse ( count($invitations), count($invitations), 1, 1, $invitations ); return $this->ok($response->toArray($expand = Request::input('expand',''))); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @param $invitation_id * @return mixed */ public function acceptInvitation($invitation_id){ try { $current_member = $this->resource_server_context->getCurrentUser(); if (is_null($current_member)) return $this->error403(); $team_member = $this->service->acceptInvitation($invitation_id, $current_member->getId()); return $this->created(SerializerRegistry::getInstance()->getSerializer($team_member)->serialize($expand = '')); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } } /** * @param $invitation_id * @return mixed */ public function declineInvitation($invitation_id){ try { $current_member = $this->resource_server_context->getCurrentUser(); if (is_null($current_member)) return $this->error403(); $this->service->declineInvitation($invitation_id, $current_member->getId()); return $this->deleted(); } catch (ValidationException $ex1) { Log::warning($ex1); return $this->error412(array($ex1->getMessage())); } catch(EntityNotFoundException $ex2) { Log::warning($ex2); return $this->error404(array('message'=> $ex2->getMessage())); } catch (\Exception $ex) { Log::error($ex); return $this->error500($ex); } } }