Skip to content

Conversation

HeahDude
Copy link
Contributor

@HeahDude HeahDude commented Nov 29, 2022

Q A
Branch? main
Tickets ~
License MIT
Doc PR ~

While trying to decorate the Symfony\Component\Serializer\Encoder\JsonEncoder (service serializer.json.encoder) we found out that it is not used by ApiPlatform\Core\Serializer\JsonEncoder as a service since the argument is not defined and one is created instead https://github.com/api-platform/core/blob/main/src/Serializer/JsonEncoder.php#L36.
So we currently need to wire the argument ourselves in a compiler pass.

Should I add a test for this?

@HeahDude HeahDude force-pushed the feat/use-sf-json-encoder branch 2 times, most recently from 794b37e to 1db01c7 Compare November 29, 2022 12:00
@HeahDude HeahDude changed the title [Bundle] Wire Symfony JsonEncoder if it exists feature(Bundle): wire Symfony JsonEncoder if it exists Nov 29, 2022
@HeahDude HeahDude force-pushed the feat/use-sf-json-encoder branch from 1db01c7 to ba187f7 Compare November 29, 2022 12:05
@HeahDude HeahDude changed the title feature(Bundle): wire Symfony JsonEncoder if it exists feat(Bundle): wire Symfony JsonEncoder if it exists Nov 29, 2022
@HeahDude HeahDude force-pushed the feat/use-sf-json-encoder branch from ba187f7 to 32100b1 Compare November 29, 2022 12:07
@HeahDude HeahDude changed the title feat(Bundle): wire Symfony JsonEncoder if it exists feat(symfony): wire Symfony JsonEncoder if it exists Nov 29, 2022
@soyuka
Copy link
Member

soyuka commented Nov 29, 2022

why don't you decorate api_platform.jsonld.encoder? I agree about the patch though can you target 3.0 please?

@HeahDude
Copy link
Contributor Author

why don't you decorate api_platform.jsonld.encoder? I agree about the patch though can you target 3.0 please?

api_platform.jsonld.encoder is not the one we need to decorate as we may use the json format one as well, so it should just reuse the json decode logic by injection.

I thought it would be considered as a feature, glad if it can be part of the next patch, even though we are not using 3.0 yet :).

@HeahDude HeahDude changed the base branch from main to 3.0 November 29, 2022 16:06
@HeahDude HeahDude force-pushed the feat/use-sf-json-encoder branch from 32100b1 to f08865f Compare November 29, 2022 16:07
@soyuka soyuka merged commit 27af321 into api-platform:3.0 Nov 29, 2022
@soyuka
Copy link
Member

soyuka commented Nov 29, 2022

thanks!

@HeahDude HeahDude deleted the feat/use-sf-json-encoder branch November 29, 2022 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants