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] Enabled mapping configuration via attributes#38525

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

Conversation

@derrabus
Copy link
Member

QA
Branch?5.x
Bug fix?no
New feature?yes
Deprecations?no
TicketsN/A
LicenseMIT
Doc PRTODO

Let's use attributes for the serializer mapping configuration!

class MyEntity{    #[Groups(['list','detail])]    #[SerializedName('some-property')]    public$someProperty;    #[Ignore]    public string$secret;}

markuspoerschke reacted with hooray emojidunglas, lyrixx, bobey, and mmounaim reacted with heart emoji
@derrabusderrabusforce-pushed theimprovement/serializer-attributes branch 2 times, most recently from62248c9 tob5953cbCompareOctober 12, 2020 11:54
@derrabus
Copy link
MemberAuthor

I was wondering is we should make theGroups attribute variadic. Instead of…

#[Groups(['list','detail'])]

… we could then write…

#[Groups('list','detail')]

This would look a bit nicer, but adding additional properties in the future would get messy.

liorchamla reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas added this to the5.2 milestoneOct 12, 2020
@fabpot
Copy link
Member

@derrabus Can you have a look at the failing tests?

@derrabusderrabusforce-pushed theimprovement/serializer-attributes branch fromb5953cb tocfb9986CompareOctober 12, 2020 12:52
@derrabus
Copy link
MemberAuthor

I used::class in annotations, but Doctrine Annotations 1.0 does not support that. Should be fixed now.

@fabpot
Copy link
Member

Thank you@derrabus.

@fabpotfabpot merged commita319090 intosymfony:5.xOct 12, 2020
@fabpotfabpot mentioned this pull requestOct 14, 2020
derrabus added a commit that referenced this pull requestNov 7, 2020
…ration of routing/serializer without doctrine/annotations (derrabus)This PR was merged into the 5.2-dev branch.Discussion---------- [FrameworkBundle] Allow to use attribute-based configuration of routing/serializer without doctrine/annotations| Q             | A| ------------- | ---| Branch?       | 5.2| Bug fix?      | no| New feature?  | yes| Deprecations? | no| Tickets       | N/A| License       | MIT| Doc PR        | N/AFollows#37474,#38525Currently, we need `doctrine/annotations` to be installed in order to configure routing and serializer via PHP attributes. Given that for both components we can already replace Doctrine Annotations completely, I'd like to get rid of that limitation.Commits-------e5492e2 [FrameworkBundle] Configure PHP Attributes without doctrine/annotations.
@derrabusderrabus deleted the improvement/serializer-attributes branchMarch 13, 2021 15:22
guillaumesmo added a commit to guillaumesmo/rector-symfony that referenced this pull requestApr 11, 2022
Support for all theses attributes was added in Symfony 5.2, together with the already present Groups attributeseesymfony/symfony#38525there is only one missing Serializer annotation, but it was added in Symfony 5.4, so I left that one outsymfony/symfony#38525
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dunglasdunglasAwaiting requested review from dunglas

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

4 participants

@derrabus@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp