mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-10 16:55:00 +00:00
Handle different export types in ExportConfigNormalizer and allow null/array checks for dataFormatter in ExportController
This commit is contained in:
6
.changes/unreleased/Fixed-20250903-211043.yaml
Normal file
6
.changes/unreleased/Fixed-20250903-211043.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
kind: Fixed
|
||||||
|
body: Fix exports to work with DirectExportInterface
|
||||||
|
time: 2025-09-03T21:10:43.957621699+02:00
|
||||||
|
custom:
|
||||||
|
Issue: ""
|
||||||
|
SchemaChange: No schema change
|
@@ -345,7 +345,7 @@ class ExportController extends AbstractController
|
|||||||
* @param array $dataExport Raw data from export step
|
* @param array $dataExport Raw data from export step
|
||||||
* @param array $dataFormatter Raw data from formatter step
|
* @param array $dataFormatter Raw data from formatter step
|
||||||
*/
|
*/
|
||||||
private function buildExportDataForNormalization(?string $alias, ?array $dataCenters, array $dataExport, ?array $dataFormatter, ?SavedExport $savedExport): array
|
private function buildExportDataForNormalization(string $alias, ?array $dataCenters, array $dataExport, ?array $dataFormatter, ?SavedExport $savedExport): array
|
||||||
{
|
{
|
||||||
if ($this->filterStatsByCenters) {
|
if ($this->filterStatsByCenters) {
|
||||||
$formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], null);
|
$formCenters = $this->createCreateFormExport($alias, 'generate_centers', [], null);
|
||||||
@@ -365,7 +365,7 @@ class ExportController extends AbstractController
|
|||||||
$formExport->submit($dataExport);
|
$formExport->submit($dataExport);
|
||||||
$dataExport = $formExport->getData();
|
$dataExport = $formExport->getData();
|
||||||
|
|
||||||
if (\count($dataFormatter) > 0) {
|
if (is_array($dataFormatter) && \count($dataFormatter) > 0) {
|
||||||
$formFormatter = $this->createCreateFormExport(
|
$formFormatter = $this->createCreateFormExport(
|
||||||
$alias,
|
$alias,
|
||||||
'generate_formatter',
|
'generate_formatter',
|
||||||
@@ -381,7 +381,7 @@ class ExportController extends AbstractController
|
|||||||
'export' => $dataExport['export']['export'] ?? [],
|
'export' => $dataExport['export']['export'] ?? [],
|
||||||
'filters' => $dataExport['export']['filters'] ?? [],
|
'filters' => $dataExport['export']['filters'] ?? [],
|
||||||
'aggregators' => $dataExport['export']['aggregators'] ?? [],
|
'aggregators' => $dataExport['export']['aggregators'] ?? [],
|
||||||
'pick_formatter' => $dataExport['export']['pick_formatter']['alias'],
|
'pick_formatter' => ($dataExport['export']['pick_formatter'] ?? [])['alias'] ?? '',
|
||||||
'formatter' => $dataFormatter['formatter'] ?? [],
|
'formatter' => $dataFormatter['formatter'] ?? [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -72,10 +72,14 @@ class ExportConfigNormalizer
|
|||||||
}
|
}
|
||||||
$serialized['aggregators'] = $aggregatorsSerialized;
|
$serialized['aggregators'] = $aggregatorsSerialized;
|
||||||
|
|
||||||
$serialized['pick_formatter'] = $formData['pick_formatter'];
|
if ($export instanceof ExportInterface) {
|
||||||
$formatter = $this->exportManager->getFormatter($formData['pick_formatter']);
|
$serialized['pick_formatter'] = $formData['pick_formatter'];
|
||||||
$serialized['formatter']['form'] = $formatter->normalizeFormData($formData['formatter']);
|
$formatter = $this->exportManager->getFormatter($formData['pick_formatter']);
|
||||||
$serialized['formatter']['version'] = $formatter->getNormalizationVersion();
|
$serialized['formatter']['form'] = $formatter->normalizeFormData($formData['formatter']);
|
||||||
|
$serialized['formatter']['version'] = $formatter->getNormalizationVersion();
|
||||||
|
} elseif ($export instanceof DirectExportInterface) {
|
||||||
|
$serialized['formatter'] = ['form' => [], 'version' => 0];
|
||||||
|
}
|
||||||
|
|
||||||
return $serialized;
|
return $serialized;
|
||||||
}
|
}
|
||||||
@@ -87,7 +91,12 @@ class ExportConfigNormalizer
|
|||||||
public function denormalizeConfig(string $exportAlias, array $serializedData, bool $replaceDisabledByDefaultData = false): array
|
public function denormalizeConfig(string $exportAlias, array $serializedData, bool $replaceDisabledByDefaultData = false): array
|
||||||
{
|
{
|
||||||
$export = $this->exportManager->getExport($exportAlias);
|
$export = $this->exportManager->getExport($exportAlias);
|
||||||
$formater = $this->exportManager->getFormatter($serializedData['pick_formatter']);
|
|
||||||
|
if ($export instanceof ExportInterface) {
|
||||||
|
$formatter = $this->exportManager->getFormatter($serializedData['pick_formatter']);
|
||||||
|
} else {
|
||||||
|
$formatter = null;
|
||||||
|
}
|
||||||
|
|
||||||
$filtersConfig = [];
|
$filtersConfig = [];
|
||||||
foreach ($serializedData['filters'] as $alias => $filterData) {
|
foreach ($serializedData['filters'] as $alias => $filterData) {
|
||||||
@@ -117,8 +126,8 @@ class ExportConfigNormalizer
|
|||||||
'export' => $export->denormalizeFormData($serializedData['export']['form'], $serializedData['export']['version']),
|
'export' => $export->denormalizeFormData($serializedData['export']['form'], $serializedData['export']['version']),
|
||||||
'filters' => $filtersConfig,
|
'filters' => $filtersConfig,
|
||||||
'aggregators' => $aggregatorsConfig,
|
'aggregators' => $aggregatorsConfig,
|
||||||
'pick_formatter' => $serializedData['pick_formatter'],
|
'pick_formatter' => $serializedData['pick_formatter'] ?? '',
|
||||||
'formatter' => $formater->denormalizeFormData($serializedData['formatter']['form'], $serializedData['formatter']['version']),
|
'formatter' => $formatter?->denormalizeFormData($serializedData['formatter']['form'], $serializedData['formatter']['version']),
|
||||||
'centers' => [
|
'centers' => [
|
||||||
'centers' => array_values(array_filter(array_map(fn (int $id) => $this->centerRepository->find($id), $serializedData['centers']['centers']), fn ($item) => null !== $item)),
|
'centers' => array_values(array_filter(array_map(fn (int $id) => $this->centerRepository->find($id), $serializedData['centers']['centers']), fn ($item) => null !== $item)),
|
||||||
'regroupments' => array_values(array_filter(array_map(fn (int $id) => $this->regroupmentRepository->find($id), $serializedData['centers']['regroupments']), fn ($item) => null !== $item)),
|
'regroupments' => array_values(array_filter(array_map(fn (int $id) => $this->regroupmentRepository->find($id), $serializedData['centers']['regroupments']), fn ($item) => null !== $item)),
|
||||||
|
Reference in New Issue
Block a user