It's my first time here so I hope so don't be to hard on me.I'm trying to develop an API Rest on Symfony4 with FosRestBundle, Doctrine2 and JMSSerializer.
Here's my problem:
I have 3 entities organized such as:
- client which contains extras and a culture
- culture
- extra
My annotations and associations are fine. But now I want to insert a client in my database by simply persist and flush my client object. The JSON I send in my body request looks like something like this:
{ client_name: "something" culture: { culture_id: x } extras: [ { extra_name: "name1" }, { extra_name: "name2" } ]}
Now what I'd like here is simple : creating a client and its extras but not its culture which I know the ID. But if I persist and flush my client entity, culture will be treated the same way. And of course I have other information in my culture entity that I don't want to update.
- Am I missing an annotation to avoid this and just take the ID culture without its content? Is there an annotation that I don't know of and that could solve this?
- Should I get the culture from the database and set it to the client first (I'd like to avoid this to save some automatisms I set up)?
Hope you'll have some ideas guys!