Open
Description
Symfony version(s) affected
7.0.7
Description
The CsvEncoder
has an option to specify the CSV headers, but it doesn't look to work as expected.
When specifying header, the CSV is generated with new columns added.
How to reproduce
$contextBuilder = (new CsvEncoderContextBuilder())
->withContext((new ObjectNormalizerContextBuilder())->withAttributes(['firstName', 'lastName']))
->withHeaders(['Prénom', 'Nom'])
->withDelimiter(';')
;
$csv = $serializer->serialize([array of entities], 'csv', $contextBuilder->toArray());
Result:
Prénom;Nom;firstName;lastName
;;Entity first name;Entity last name
Expected result:
Prénom;Nom
Entity first name;Entity last name
Possible Solution
Probably something wrong here:
Additional Context
No response