fix handling of DirectExportInterface

This commit is contained in:
2023-06-25 15:47:30 +02:00
parent 9978b6a6e4
commit 0e9597bf77
2 changed files with 21 additions and 13 deletions

View File

@@ -72,17 +72,21 @@ final readonly class ExportFormHelper
];
}
$allowedFormatters = $this->exportManager
->getFormattersByTypes($export->getAllowedFormattersTypes());
$choices = [];
foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) {
$choices[] = $alias;
}
if ($export instanceof ExportInterface) {
$allowedFormatters = $this->exportManager
->getFormattersByTypes($export->getAllowedFormattersTypes());
$choices = [];
foreach (array_keys(iterator_to_array($allowedFormatters)) as $alias) {
$choices[] = $alias;
}
$data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) {
1 => $choices[0],
default => null,
};
$data[ExportType::PICK_FORMATTER_KEY]['alias'] = match (count($choices)) {
1 => $choices[0],
default => null,
};
} else {
unset($data[ExportType::PICK_FORMATTER_KEY]);
}
return $data;
}