-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[ObjectMapper] embed collection transformer #60442
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
36eef03
to
2da896a
Compare
src/Symfony/Component/ObjectMapper/Tests/Fixtures/TransformCollection/A.php
Outdated
Show resolved
Hide resolved
We're already using this on a project and it works quite well. |
How do you use it? How is this supposed when using sources only? class UserDto {
/**
* @var OrganizationMembershipDto[]
*/
#[Map(transform: new MapCollection(), source: "memberships")]
public array $memberships;
}
will throw:
Like ive mentioned in #61116 theres is currently no API in object mapper to provide metadata to transformers and without this transformers are unable to guess type of target value. TDLR; Only works when mapping target is defined on source. |
39aab74
to
68b8bdd
Compare
src/Symfony/Component/ObjectMapper/Tests/Fixtures/TransformCollection/TransformCollectionC.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/ObjectMapper/Tests/Fixtures/TransformCollection/TransformCollectionD.php
Outdated
Show resolved
Hide resolved
Thank you @soyuka. |
This is another approach to embeded collection mapping that avoids changing the ObjectMapper. Even if this doesn't land in the component it'd be a good thing to document. Let me know your thoughts.