mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Refactor export generation to handle saved exports conditionally
Simplified the creation of `ExportGeneration` by introducing a `match` expression to handle cases with and without `savedExport`. This improves readability and ensures consistent handling of saved exports while normalizing configuration options.
This commit is contained in:
parent
e8bca6a502
commit
fe31cfd544
@ -316,13 +316,14 @@ class ExportController extends AbstractController
|
|||||||
$savedExport,
|
$savedExport,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->entityManager->persist(
|
$deleteAt = $this->clock->now()->add(new \DateInterval('P6M'));
|
||||||
$exportGeneration = new ExportGeneration(
|
$options = $this->exportConfigNormalizer->normalizeConfig($alias, $dataToNormalize);
|
||||||
$alias,
|
$exportGeneration = match (null === $savedExport) {
|
||||||
$this->exportConfigNormalizer->normalizeConfig($alias, $dataToNormalize),
|
true => new ExportGeneration($alias, $options, $deleteAt),
|
||||||
$this->clock->now()->add(new \DateInterval('P6M')),
|
false => ExportGeneration::fromSavedExport($savedExport, $deleteAt, $options),
|
||||||
),
|
};
|
||||||
);
|
|
||||||
|
$this->entityManager->persist($exportGeneration);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
$this->messageBus->dispatch(new ExportRequestGenerationMessage($exportGeneration, $user));
|
$this->messageBus->dispatch(new ExportRequestGenerationMessage($exportGeneration, $user));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user