[ 'name_template' => $data->getName(), 'content_template' => $data->getTemplateContent(), ] ]; $bootServer = $data->getBootServer(); if (!$bootServer) { throw new BadRequestHttpException('This PxeTemplate is not attached to any BootServer.'); } $this->logger->info(sprintf('Synchronizing PxeTemplate "%s" to BootServer "%s" at IP %s', $data->getName(), $bootServer->getName(), $bootServer->getIp())); $content = $this->createRequestFromBootServer($bootServer, 'POST', '/ogboot/v1/pxe-templates' , $params); if (isset($content['error']) ) { $data->setSynchronized(false); $this->entityManager->persist($data); $this->entityManager->flush(); throw new BadRequestHttpException('Sync failed: ' . ($content['message'] ?? $content['error'])); } $data->setSynchronized(true); $this->entityManager->persist($data); $this->entityManager->flush(); return new JsonResponse(data: $content, status: Response::HTTP_OK); } }