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

[HttpKernel] Map a list of items withMapRequestPayload attribute#54385

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
chalasr merged 1 commit intosymfony:7.1fromyceruto:feature/array_payload
Apr 6, 2024

Conversation

@yceruto
Copy link
Member

@ycerutoyceruto commentedMar 23, 2024
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
Issues-
LicenseMIT

Request:

Content-Type: application/json[    {"price":50},    {"price":23}]

Controller:

class MyController{publicfunction__invoke(        #[MapRequestPayload(type: Price::class)]array$prices,    ):Response {// do something with $prices -> array<Price>    }}

Cheers!

chalasr, welcoMattic, wkania, and alamirault reacted with thumbs up emojikaznovac reacted with rocket emoji
@carsonbotcarsonbot added this to the7.1 milestoneMar 23, 2024
@ycerutoycerutoforce-pushed thefeature/array_payload branch 2 times, most recently fromef669f4 to24f3cc7CompareMarch 24, 2024 16:00
@smnandre
Copy link
Member

Couple of questions there:

  • Would this work with forms, or XML ?
  • Does the validation still work ?

@yceruto
Copy link
MemberAuthor

Couple of questions there:
Would this work with forms, or XML ?

The feature behind this improvement is completely agnostic to the request format. It will work with any data format supported by the Serializer component. See more here:https://symfony.com/doc/current/components/serializer.html#handling-arrays

Does the validation still work ?

Yes, the validator component does support any iterable value.

@smnandre
Copy link
Member

I did not see how a form could send data as flat array at first... hence my question. But i'm indeed not aware of all the possibilties offered by the serializer there.

(for the validation i was referring to thevalidationGroups attribute.. just to know how this would compare to the nested array of DTOs for instance)

@yceruto
Copy link
MemberAuthor

(for the validation i was referring to the validationGroups attribute.. just to know how this would compare to the nested array of DTOs for instance)

If set, it will be applied to each element of the collection as implemented here:

privatefunctionvalidateEachObjectIn(iterable$collection,string$propertyPath,array$groups,ExecutionContextInterface$context):void

smnandre reacted with thumbs up emoji

@ycerutoycerutoforce-pushed thefeature/array_payload branch from24f3cc7 to39e1651CompareMarch 25, 2024 15:29
@ycerutoycerutoforce-pushed thefeature/array_payload branch 4 times, most recently from42bbd07 to38a7cddCompareMarch 25, 2024 18:16
@ycerutoycerutoforce-pushed thefeature/array_payload branch from38a7cdd to948e65bCompareMarch 25, 2024 19:49
@ycerutoycerutoforce-pushed thefeature/array_payload branch from948e65b to00ec79aCompareMarch 25, 2024 21:47
@ycerutoycerutoforce-pushed thefeature/array_payload branch from00ec79a to5bca3e0CompareMarch 26, 2024 13:05
@chalasr
Copy link
Member

At some point, the new TypeInfo component could certainly help guessing what$type is (when possible)

mtarld, welcoMattic, Koc, and yceruto reacted with thumbs up emojismnandre reacted with eyes emoji

@ycerutoyceruto added the ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" labelApr 2, 2024
@ycerutoycerutoforce-pushed thefeature/array_payload branch from5bca3e0 to3f72143CompareApril 5, 2024 19:59
@chalasr
Copy link
Member

Nice one. Thanks Yonel!

yceruto reacted with heart emoji

@chalasrchalasr merged commit9549cc2 intosymfony:7.1Apr 6, 2024
@ycerutoyceruto deleted the feature/array_payload branchApril 6, 2024 13:18
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestApr 16, 2024
…e (yceruto)This PR was merged into the 7.1 branch.Discussion----------Documenting items type in the MapRequestPayload attributeFixes#19761PR:symfony/symfony#54385Commits-------fa1934c Documenting items type in the MapRequestPayload attribute
@fabpotfabpot mentioned this pull requestMay 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@welcoMatticwelcoMatticwelcoMattic left review comments

@chalasrchalasrchalasr approved these changes

@lyrixxlyrixxAwaiting requested review from lyrixx

Assignees

No one assigned

Labels

FeatureHttpKernel❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze"Status: Reviewed

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

6 participants

@yceruto@smnandre@chalasr@nicolas-grekas@welcoMattic@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp