public function readAction($request, $response, $userId, GetTicketsService $getTicketsService) { try { $role = $this->container->has('jwt') ? $this->container->get('jwt')->role : 'admin'; $status = $request->getParam('status') ? $request->getParam('status') : null; $serviceRequest = new GetTicketsRequest([ 'userId' => $userId, 'role' => $role, 'status' => $status, ]); /* * Tickets are already an array */ $tickets = $getTicketsService->execute($serviceRequest); return $response->withJson($tickets); } catch (\Exception $e) { $code = (int) $e->getCode() > 200 && (int) $e->getCode() <= 500 ? (int) $e->getCode() : 500; return $response->withStatus($code)->withJson(ErrorResponse::createFromException($e)); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter