diff --git a/src/Service/DataSynchronizationService.php b/src/Service/DataSynchronizationService.php index 1d5c53b9..71e4294c 100644 --- a/src/Service/DataSynchronizationService.php +++ b/src/Service/DataSynchronizationService.php @@ -18,6 +18,7 @@ use App\Repository\AccountRepository; use App\Repository\ClientRepository; use App\Repository\DataProviderRepository; +use App\Repository\EpicRepository; use App\Repository\InvoiceRepository; use App\Repository\IssueRepository; use App\Repository\ProjectRepository; @@ -45,6 +46,7 @@ public function __construct( private readonly DataProviderService $dataProviderService, private readonly DataProviderRepository $dataProviderRepository, private readonly WorkerRepository $workerRepository, + private readonly EpicRepository $epicRepository, ) { } @@ -271,6 +273,26 @@ public function syncIssuesForProject(int $projectId, ?callable $progressCallback } } + $epicArray = explode(',', $issueDatum->epicName); + + foreach ($epicArray as $epicTitle) { + if (empty($epicTitle)) { + continue; + } + $epic = $this->epicRepository->findOneBy([ + 'title' => $epicTitle, + ]); + + if (!$epic) { + $epic = new Epic(); + $epic->setTitle($epicTitle); + $this->entityManager->persist($epic); + $this->entityManager->flush(); + } + + $issue->addEpic($epic); + } + if (null !== $progressCallback) { $progressCallback($issuesProcessed, $total); ++$issuesProcessed;