Hi,
I have an ImageDataObject with a 1- relation to Image.
If the Image is deleted (fx in Files and Images), the related ImageDataObject isn't necessary anymore.
So I'm trying to automate the deletion of the ImageDataObject, but I'm kind of stuck...
This is what I have right now:
class MyImageDecorator extends DataObjectDecorator {
...
public function onBeforeDelete() {
$query = new SQLQuery('*', array('ImageDataObject'), $ImageID = $this->ID);
$query->delete = true;
$query->execute();
parent::onBeforeDelete();
}
}
However, this prevents the deletion of the image in Files and Images.
Can someone see what I'm doing wrong and/or give me some advice on automating it?