viewHandler = $viewHandler; $this->repository = $repository; } /** * @SWG\Response( * response=200, * description="Returns the collection of all registered users", * @SWG\Schema(ref="#/definitions/UserCollection"), * ) * * @Security("is_granted('view_user')") * * @return Response */ public function cgetAction() { $data = $this->repository->findAll(); $view = new View($data, 200); $view->getContext()->setGroups(['Default', 'Collection', 'User']); return $this->viewHandler->handle($view); } /** * @SWG\Response( * response=200, * description="Return one user entity", * @SWG\Schema(ref="#/definitions/UserEntity"), * ) * * @Security("is_granted('view_user')") * * @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', 'User']); return $this->viewHandler->handle($view); } }