Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
85 stars 28 forks source link

unique constraint " name + locale " #61

Open rsereir opened 1 year ago

rsereir commented 1 year ago

hello !

i try to add unique constraint on my translations with name + locale fields to not have duplications on my translation entities but when i try to remplace my translations collection of my translatable entity without any modifications, my constraint is trigged because doctrine try to add new translations ( instead of update existing ).

I analyse the unique constraint validator of symfony and i see i loss my id on translations objects when valid is called. someone have any idea ?

Rédoine

kevinG73 commented 1 year ago

Hello @rsereir , If you use API PLATFORM 3 you can to use state processors to perform any operation before saving in the database.

rsereir commented 1 year ago

@kevinG73 hello !

Thanks for your answer, but i really want to know why i loss my translation id on update translations :)

Make a custom state processor is working if i rewrite all of validation process, all of translation persistance, but i just want to use properly UniqueEntity constraint of symfony, without custom state process, it's just a "classic" api call.