Skip to content

[ObjectMapper] allow owning ObjectMapper object #61145

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

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

soyuka
Copy link
Contributor

@soyuka soyuka commented Jul 17, 2025

Q A
Branch? 7.4
Feature? yes
Issues Fix #61119
License MIT

Because the Object Mapper calls itself and we don't offer the possibility to change the owning object mapper, its hard to change the behavior on embedded objects (you could with a transform callable but it is redundant and adds lots of complexity).
With this change the ObjectMapper can use a decorated instance and we can easily provide a way to make things like #61119 work. Inside API Platform we have the same issue where we want to re-use values that have been previously mapped to existing entities, we don't want to create new classes. This is achievable with decorating the ObjectMapper but works on relations only if the called mapper inside the mapper is configurable.

Let me know how I should write the DI in the FrameworkBundle for this as it'd be nice if it worked with decoration pattern without user interactions.

@soyuka soyuka force-pushed the fix/embed branch 2 times, most recently from 914bdc1 to f54ea10 Compare July 17, 2025 20:25
@soyuka
Copy link
Contributor Author

soyuka commented Jul 17, 2025

I guess we should consider this as a new feature though as we added a new interface and a public method, I rebased on 7.4.

@soyuka soyuka changed the base branch from 7.3 to 7.4 July 17, 2025 20:25
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Can you please add a line to the changelog of the component?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ObjectMapper] Mapping to existing entity doesn't work always
3 participants