Esempio n. 1
0
 public function delete($con = null)
 {
     foreach (sfMixer::getCallables('BasesfCounter: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(sfCounterPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         sfCounterPeer::doDelete($this, $con);
         $this->setDeleted(true);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     foreach (sfMixer::getCallables('BasesfCounter:delete:post') as $callable) {
         call_user_func($callable, $this, $con);
     }
 }
 /**
  * Post delete hook : when a countable object is deleted, also deletes the
  * associated counter
  * 
  * @param      BaseObject  $object
  */
 public function postDelete(BaseObject $object)
 {
     $c = new Criteria();
     $c->add(sfCounterPeer::COUNTABLE_MODEL, get_class($object));
     $c->add(sfCounterPeer::COUNTABLE_ID, $object->getPrimaryKey());
     sfCounterPeer::doDelete($c);
 }