refs #658. Updated sync endpoint ogBoot

develop-jenkins
Manuel Aranda Rosales 2024-09-13 09:52:13 +02:00
parent 8bfc471144
commit efdf60778a
1 changed files with 19 additions and 1 deletions

View File

@ -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();
}
}