Propel2 icon indicating copy to clipboard operation
Propel2 copied to clipboard

Behavior hook for DELETE

Open marcoas opened this issue 2 years ago • 0 comments

(Translated by Google)

Hello

I have already created and loaded for all the tables, a behavior very similar to the example in: timestampable. There, I override the preInsert and preUpdate methods. That works very well.

Now I need to be able to control this situation:

  • When doing a DELETE and it fails due to a foreign key constraint, I want to catch the error, and perform a particular action. In my case, perform a "logical delete" (set the "disabled" field of the record to true)

Can this be done with a behavior?

I tried to do it with the postDelete hook, but due to the constraint error, this method does not get executed.

I tried putting a delete function in the behavior, with the intention of overriding that method, but it doesn't seem to work or I didn't do it right.

Can someone tell me how to do this?

marcoas avatar Feb 24 '23 16:02 marcoas