Add preserve_empty_objects support#4363
Conversation
|
Or maybe CollectionNormalizers should stop supporting empty Countables |
de05be2 to
b0d548a
Compare
|
+1 for this :) WDTY about calling the normalizer on normalizeRawCollection and fully delegate the "PRESERVE_EMPTY_OBJECTS" management to Symfony ? I have found a temporary workaround. Add "PRESERVE_EMPTY_OBJECTS" in your entity normalizationContext and declare your property as |
Wow this PR seems terribly bad for me. It breaks list array at all. I am currently using PRESERVE_EMPTY_OBJECTS in global context and this behaviour feels expected for me |
About this PR, you shouldn't worry about it :) think it won't break your current behavior. You will just be able to override this for a specific property. |
According to PR ObjectNormalizer will convert all empty arrays to objects, when PRESERVE_EMPTY_OBJECTS enabled. It sounds weird for me and breaks BC. |
|
symfony/symfony#42240 irrelevant. |
b0d548a to
60b38c4
Compare
|
Added tests |
58ade62 to
fdbd75a
Compare
|
Could you target main? |
44116fd to
2235366
Compare
|
@soyuka done |
|
You must rebase your branch there are conflicts |
2235366 to
a40edca
Compare
|
Thank :) |
|
Superseded by #4999, thank you! |
CollectionNormalizer currently replacing ArrayObject with an empty array
More about main idea discussed here symfony/symfony#28363
Feel free to help me with test case and test location. Thank you 😄