开发者

Doctrine hook to validate record references onInsert

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜