entityService = $entityService; } public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { $id = $request->getAttribute('id'); $result = $this->entityService->delete($id); $return = new JsonResponse($result); if (false === $result) { return $return->withStatus(500, 'Failed to delete record.'); } return $return; } }