createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/oglives'); foreach ($content['message'] as $ogLive) { $ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]); if ($ogLiveEntity) { $this->extracted($ogLiveEntity, $ogLive); $this->entityManager->persist($ogLiveEntity); } else { $ogLiveEntity = new OgLive(); $this->extracted($ogLiveEntity, $ogLive); } $this->entityManager->persist($ogLiveEntity); } $this->entityManager->flush(); //$this->serDefaultOgLive($content['default_oglive']); return new JsonResponse(data: $content, status: Response::HTTP_OK); } /** * @param OgLive|null $ogLiveEntity * @param mixed $ogLive * @return void */ private function extracted(OgLive|null $ogLiveEntity, mixed $ogLive): void { $ogLiveEntity->setName($ogLive['directory']); $ogLiveEntity->setInstalled(true); $ogLiveEntity->setArchitecture($ogLive['architecture']); $ogLiveEntity->setDistribution($ogLive['distribution']); $ogLiveEntity->setFilename($ogLive['directory']); $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(); } }