示例#1
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(PagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = PageQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // referenceable behavior
         if (ReferencePeer::hasReference($this)) {
             throw new PropelException("Exception in " . __METHOD__ . ": tried removing an instance from the database even though it is still referenced.", new StillReferencedException($this));
         }
         // denyable behavior
         if (!(PagePeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.custom", array("role_key" => "pages")));
         }
         // nested_set behavior
         if ($this->isRoot()) {
             throw new PropelException('Deletion of a root node is disabled for nested sets. Use PagePeer::deleteTree() instead to delete an entire tree');
         }
         if ($this->isInTree()) {
             $this->deleteDescendants($con);
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             // nested_set behavior
             if ($this->isInTree()) {
                 // fill up the room that was used by the node
                 PagePeer::shiftRLValues(-2, $this->getRightValue() + 1, null, $con);
             }
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
示例#2
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(LinkPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = LinkQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // referenceable behavior
         if (ReferencePeer::hasReference($this)) {
             throw new PropelException("Exception in " . __METHOD__ . ": tried removing an instance from the database even though it is still referenced.", new StillReferencedException($this));
         }
         // denyable behavior
         if (!(LinkPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "links")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }