I've an Attachment
model that stores file metadata in MySQL and actual file on file system. I've implemented deletion with Callback Methods:
public function beforeDelete($cascade = true) {
$this->data = $this->findById($this->id);
return parent::beforeDelete($cascade);
}
public function afterDelete() {
$file = new File($this->data['Attachment']['path']);
$file->delete();
}
Is there a way to determine if there's an open transaction and only perform the file system deletion if such transaction gets committed? (Transaction is of course handled in the controller, which may not even be AttachmentsCrontroller
but some other.)