public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { $result = $this->repository->findAll(); if ($result->count() == 0) { return new JsonResponse('', 204); } return new JsonResponse(['data' => $result->toArray()]); }
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { $id = $request->getAttribute('resourceId'); $user = $this->repository->find(new Uuid($id)); if (!$user) { throw new ApiProblemException('User not found', 404); } return new JsonResponse(['data' => $user]); }
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { $id = $request->getAttribute('resourceId'); $user = $this->repository->find(new Uuid($id)); if (!$user) { throw new ApiProblemException('User not found', 404); } $result = $this->repository->remove($user); // @codeCoverageIgnoreStart if (!$result) { throw new ApiProblemException('Error while trying to delete the user', 500); } // @codeCoverageIgnoreEnd return new JsonResponse('', 204); }