开发者

Doctrine hook to validate record references onInsert

开发者 https://www.devze.com 2023-02-08 03:35 出处:网络
I want to add Product if and only if it has say at least two Variants (Product can have many Variants).

I want to add Product if and only if it has say at least two Variants (Product can have many Variants).

How to validatate this in doctrine's preInsert or postInsert hook and stop transaction if there are not enough Variants? I know how to check scalar field using $event->getModified() or $event->data, but wondering if it is possible with whole relations especially if record has not been inserted to database yet. I mean both Many to Ma开发者_JAVA技巧ny and One to Many relations.


there are special hooks for validation that you can use to easily implement this functionality: validate(), validateOnInsert() and validateOnUpdate()

0

精彩评论

暂无评论...
验证码 换一张
取 消