Improved EntityExporter to handle recursive exports

This commit is contained in:
Jan Böhmer 2024-06-23 00:11:38 +02:00
parent f6e955b487
commit bbf7222a6a
2 changed files with 26 additions and 1 deletions

View file

@ -51,7 +51,7 @@ class StructuralElementNormalizer implements NormalizerInterface
/**
* @return array<string, mixed>
*/
public function normalize($object, string $format = null, array $context = []): array
public function normalize($object, string $format = null, array $context = []): mixed
{
if (!$object instanceof AbstractStructuralDBElement) {
throw new \InvalidArgumentException('This normalizer only supports AbstractStructural objects!');
@ -59,6 +59,10 @@ class StructuralElementNormalizer implements NormalizerInterface
$data = $this->normalizer->normalize($object, $format, $context);
if (!is_array($data)) {
return $data;
}
//Remove type field for CSV export
if ($format === 'csv') {
unset($data['type']);