refs #658. Updated sync endpoint ogBoot
parent
8bfc471144
commit
efdf60778a
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue