core
core copied to clipboard
feat(doctrine): new hook for entity/document transformation
| Q | A |
|---|---|
| Branch? | main |
| License | MIT |
| Doc PR | TODO |
Currently when using stateOptions to specify the entityClass (or documentClass) for your custom ApiResource, the standard StateProviders do exactly what you need most of the time, but you still often need to write custom providers to correctly map the entity/document to the actual resource.
This adds the possibility to specify a hook (the same way you specify custom a handleLinks method) to transform the doctrine entity or document into the desired ApiResource without having to write a full custom StateProvider.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
just a comment to stop this from closing, trying to find the time to complete this.
sorry my bad :)
At long last I found some time to revisit this PR. @soyuka what do you think ?
I haven't looked at how it fits in with https://github.com/api-platform/core/pull/6801 yet, but i guess that would be a default implementation of the ResourceTransformerInterface using the Mapper symfony extension if it's available.
My question is more: doesn't object mapper already does the transformation hook ? I'm not sure we need a transformation hook when using the object mapper. If you mark a class with the Map attribute it'll be transformed.
My question is more: doesn't object mapper already does the transformation hook ? I'm not sure we need a transformation hook when using the object mapper. If you mark a class with the
Mapattribute it'll be transformed.
I haven't looked in depth at what ObjectMapper can do yet, and it's entirely possible what i was doing is now redundant.
Let me try to do what i had in mind with it, if it works as i hope i'll just close this PR.
from what we discussed I think we can close this, let me know if its still relevant!