Skip to content

How to link doctrine resource with API resource not mapped with doctrine #5557

Answered by soyuka
KerianMM asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

Indeed, stateOptions or extraProperties are ways to extend our metadata to your liking.
We do this a lot when creating APIs, as it's very useful (for example to avoid serialization groups). For this to be automatic, we either do the mapping by hand or use a mapper (proposal for a new Symfony component: symfony/symfony#51741), check also the Symfony casts on the subject (also uses a micro-mapper).

You can find an example with the proposed component at: https://github.com/soyuka/api-platform-doctrine-mapper/blob/main/src/State/BookProvider.php#L14. At some point I'd like this to be in the core.

Now the last thing you need is to use your Provider on every resource or entity/resource tupl…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by soyuka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants