diff --git a/src/Controller/OgBoot/OgLive/SyncAction.php b/src/Controller/OgBoot/OgLive/SyncAction.php index dfabadb..4083309 100644 --- a/src/Controller/OgBoot/OgLive/SyncAction.php +++ b/src/Controller/OgBoot/OgLive/SyncAction.php @@ -4,6 +4,7 @@ namespace App\Controller\OgBoot\OgLive; use App\Controller\OgBoot\AbstractOgBootController; use App\Entity\OgLive; +use App\Model\OgLiveStatus; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; @@ -40,6 +41,7 @@ class SyncAction extends AbstractOgBootController $this->entityManager->persist($ogLiveEntity); } $this->entityManager->flush(); + $this->serDefaultOgLive($content['default_oglive']); return new JsonResponse(data: $content, status: Response::HTTP_OK); } @@ -49,14 +51,30 @@ class SyncAction extends AbstractOgBootController * @param mixed $ogLive * @return void */ - public function extracted(OgLive|null $ogLiveEntity, mixed $ogLive): void + private function extracted(OgLive|null $ogLiveEntity, mixed $ogLive): void { $ogLiveEntity->setName($ogLive['filename']); $ogLiveEntity->setInstalled(true); $ogLiveEntity->setArchitecture($ogLive['architecture']); + $ogLiveEntity->setDistribution($ogLive['distribution']); + $ogLiveEntity->setFilename($ogLive['filename']); $ogLiveEntity->setKernel($ogLive['kernel']); $ogLiveEntity->setRevision($ogLive['revision']); $ogLiveEntity->setDirectory($ogLive['directory']); $ogLiveEntity->setChecksum($ogLive['id']); + $ogLiveEntity->setStatus(OgLiveStatus::ACTIVE); + } + + private function serDefaultOgLive(string $defaultOgLive): void + { + $ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['name' => $defaultOgLive]); + + if (!$ogLiveEntity) { + return; + } + + $ogLiveEntity->setIsDefault(true); + $this->entityManager->persist($ogLiveEntity); + $this->entityManager->flush(); } } \ No newline at end of file