[Flow] Re: Cascade remove not working (Integrity constraint violation)
Christian EÃl
essl at incert.at
Mon Sep 9 11:56:07 CEST 2013
Another workaround...
I added this function to the model:
-----------------------
/**
* @ORM\PreRemove
* Delete all associated images on remove
*/
public function preRemove() {
foreach($this->images as $image) {
$image->setGallery(null);
$this->removeImage($image);
}
$this->persistenceManager->persistAll();
}
-----------------------
and this annotation to the model to notify doctrine that my model uses LifecycleCallbacks:
-----------------------
* @ORM\HasLifecycleCallbacks
class Gallery {
.
}
-----------------------
Now the images really get deleted before the gallery is removed. Altough I don't get it why my "cascade={"all"}, orphanRemoval=true" annotations are ignored (in other models it works as expected)
More information about the Flow
mailing list