getId()) { throw new BadRequestHttpException('Data Id is required'); } try { $content = $this->createRequest( 'DELETE', 'http://' . $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets/' . $data->getServerId() ); } catch (HttpException $e) { if ($e->getStatusCode() === 404) { $content = ['message' => 'Subnet not found on external API, proceeding with local deletion']; } else { throw $e; } } $this->entityManager->remove($data); $this->entityManager->flush(); return new JsonResponse(data: $content, status: Response::HTTP_OK); } }