[Flow] Cascade remove not working (Integrity constraint violation)
Winfried Mingst
admin at regionalberatung.at
Mon Sep 9 13:01:47 CEST 2013
sorry, my last posting refers to another thread.
Am 09.09.2013 12:52, schrieb Winfried Mingst:
> I did it similar to you. I used "real-ajax-uploader", which does all
> that hidden things automatically. Besides it also works with non
> HTML5-browsers.
>
>
> Am 09.09.2013 11:56, schrieb Christian Eßl:
>> 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