コード例 #1
0
 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()]);
 }
コード例 #2
0
 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]);
 }
コード例 #3
0
 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);
 }