I have a listener which contains a preSave() method. Is there a way for me to halt doctrine from calling the save method if a condition fails. Unfortunately I am not allowed to throw an exception. Is there any other way?
+2
A:
My first idea would be to set a flag in the preSave()-method and to check for that flag in the save()-method. But I think skipOperation() is what you are looking for:
public function preSave(Doctrine_Event $event)
{
if (!$condition) {
$event->skipOperation();
}
}
Thomas Schuster
2010-07-21 12:55:54
Wow that is awesome! I never knew about skipOperation! Awesome!
balupton
2010-07-21 13:04:21
i will try the skipOperation.......but I am not sure about the flag approach since the preSave() is called after the save() method of our model but before the Doctrine_Record'd save() method
rahul
2010-07-22 21:08:27