Example #1
0
 public function delete($con = null)
 {
     foreach (sfMixer::getCallables('BaseResourceVersion:delete:pre') as $callable) {
         $ret = call_user_func($callable, $this, $con);
         if ($ret) {
             return;
         }
     }
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(ResourceVersionPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         ResourceVersionPeer::doDelete($this, $con);
         $this->setDeleted(true);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     foreach (sfMixer::getCallables('BaseResourceVersion:delete:post') as $callable) {
         call_user_func($callable, $this, $con);
     }
 }
 /**
  * This hook is called just after a resource is deleted and takes care of deleting its version history.
  */
 public function postDelete(BaseObject $resource)
 {
     $c = new Criteria();
     $c->add(ResourceVersionPeer::RESOURCE_ID, $resource->getPrimaryKey());
     $c->add(ResourceVersionPeer::RESOURCE_NAME, get_class($resource));
     ResourceVersionPeer::doDelete($c);
 }