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,
|
||||
);
|
||||
|
||||
$this->entityManager->persist(
|
||||
$exportGeneration = new ExportGeneration(
|
||||
$alias,
|
||||
$this->exportConfigNormalizer->normalizeConfig($alias, $dataToNormalize),
|
||||
$this->clock->now()->add(new \DateInterval('P6M')),
|
||||
),
|
||||
);
|
||||
$deleteAt = $this->clock->now()->add(new \DateInterval('P6M'));
|
||||
$options = $this->exportConfigNormalizer->normalizeConfig($alias, $dataToNormalize);
|
||||
$exportGeneration = match (null === $savedExport) {
|
||||
true => new ExportGeneration($alias, $options, $deleteAt),
|
||||
false => ExportGeneration::fromSavedExport($savedExport, $deleteAt, $options),
|
||||
};
|
||||
|
||||
$this->entityManager->persist($exportGeneration);
|
||||
$this->entityManager->flush();
|
||||
$this->messageBus->dispatch(new ExportRequestGenerationMessage($exportGeneration, $user));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user