public function delete(Doctrine_Connection $conn = null) { if ($conn == null) { $conn = $this->_table->getConnection(); } try { $conn->beginTransaction(); foreach ($this->_table->getTemplates() as $template) { if (method_exists($template, 'onObjectDelete')) { $template->setInvoker($this); $template->onObjectDelete($conn); } } //gotta soft delete Relationships, they won't cascade due to entity's SoftDelete $q = LsDoctrineQuery::create()->delete('Relationship r')->where('r.entity1_id = ? OR r.entity2_id = ?', array($this->id, $this->id))->execute(); //same with LsListEntity records $q = LsDoctrineQuery::create()->delete('LsListEntity le')->where('le.entity_id = ?', $this->id)->execute(); $ret = parent::delete($conn); $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw $e; } return $ret; }