Skip to content

[ObjectMapper] Add ObjectMapperAwareInterface to set the owning object mapper instance #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

Merged
merged 1 commit into from
Jul 21, 2025

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.

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?

@soyuka
Copy link
Contributor Author

soyuka commented Jul 21, 2025

done

@soyuka
Copy link
Contributor Author

soyuka commented Jul 21, 2025

let me resolve the conflicts

@nicolas-grekas nicolas-grekas changed the title [ObjectMapper] allow owning ObjectMapper object [ObjectMapper] * Add ObjectMapperAwareInterface to set the owning object mapper instance Jul 21, 2025
@nicolas-grekas nicolas-grekas changed the title [ObjectMapper] * Add ObjectMapperAwareInterface to set the owning object mapper instance [ObjectMapper] Add ObjectMapperAwareInterface to set the owning object mapper instance Jul 21, 2025
@nicolas-grekas
Copy link
Member

Thank you @soyuka.

@nicolas-grekas nicolas-grekas merged commit 5db13d5 into symfony:7.4 Jul 21, 2025
10 of 11 checks passed
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
5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy