viewHandler = $viewHandler; $this->repository = $repository; } /** * Fetch all existing teams * * @SWG\Response( * response=200, * description="Returns the collection of all existing teams", * @SWG\Schema( * type="array", * @SWG\Items(ref="#/definitions/TeamCollection") * ) * ) * * @Security("is_granted('view_team')") * * @return Response */ public function cgetAction(ParamFetcherInterface $paramFetcher) { $data = $this->repository->findAll(); $view = new View($data, 200); $view->getContext()->setGroups(['Default', 'Collection', 'Team']); return $this->viewHandler->handle($view); } /** * Returns one team * * @SWG\Response( * response=200, * description="Returns one team entity", * @SWG\Schema(ref="#/definitions/TeamEntity"), * ) * * @param int $id * @return Response */ public function getAction($id) { $data = $this->repository->find($id); if (null === $data) { throw new NotFoundException(); } $view = new View($data, 200); $view->getContext()->setGroups(['Default', 'Entity', 'Team']); return $this->viewHandler->handle($view); } /** * Delete a team * * @SWG\Delete( * @SWG\Response( * response=204, * description="Delete one team" * ), * ) * @SWG\Parameter( * name="id", * in="path", * type="integer", * description="Team ID to delete", * required=true, * ) * * @Security("is_granted('delete_team')") * * @param int $id * @return Response */ public function deleteAction($id) { $team = $this->repository->find($id); if (null === $team) { throw new NotFoundException(); } $this->repository->deleteTeam($team); $view = new View(null, Response::HTTP_NO_CONTENT); return $this->viewHandler->handle($view); } }