Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Serializer] Fixed framework.serializer.default_context is not working for JsonEncoder#45554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromsiganushka:5.4
Sep 28, 2022

Conversation

@siganushka
Copy link
Contributor

@siganushkasiganushka commentedFeb 25, 2022
edited
Loading

Fixedframework.serializer.default_context is not working forJsonEncoder

likeXmlEncoder orDateTimeNormalizer, thearray $defaultContext argument bindings fromSerializerPass, but not working forJsonEncoder, I addedarray $defaultContext argument and passed toJsonEncode andJsonDecode.

https://github.com/symfony/serializer/blob/5.4/DependencyInjection/SerializerPass.php#L69-L75

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no

Copy link
Member

@dunglasdunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ad this is a new feature, this should target the 5.c branch. Also, maybe should we allow providing different contexts for encoding and decoding.

protected$decodingImpl;

publicfunction__construct(JsonEncode$encodingImpl =null,JsonDecode$decodingImpl =null)
publicfunction__construct(array$defaultContext = [],JsonEncode$encodingImpl =null,JsonDecode$decodingImpl =null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a BC break, could you move this parameter at the end of the list please?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I understand, but I'm not sure how to set differentdefaultContext for encoding and decoding, becauseJsonEncode andJsonDecode are not passed intoJsonEncoder as a service, and other places are the samedefaultContext set inframework.serializer.default_context, LikeXmlEncoder orDateTimeNormalizer.

also I have tried providing thedefaultContext parameter at the end, but this raises an error inDefinitionErrorExceptionPass:

Invalid constructor argument 3 for service "serializer.encoder.json": argument 1 must be defined before. Check your service definition.

Do you have any idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actually, the proper solution is maybe to register them as services indeed!

kaznovac reacted with thumbs up emoji
@fabpot
Copy link
Member

@siganushka Are you still interested in moving this PR forward?

@nicolas-grekas
Copy link
Member

Thank you@siganushka.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dunglasdunglasdunglas requested changes

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

5 participants

@siganushka@fabpot@nicolas-grekas@dunglas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp