/**
  * Initialize
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     $aliasManager = new Comments_Model_CommentAlias_Manager();
     // get the Alias by the requested param
     $this->_alias = $aliasManager->getDbTable()->find($this->getRequest()->getParam('alias'))->current();
 }
Beispiel #2
0
 /**
  * Decrement comments amount
  *
  * @param integer $count
  * @throws Zend_Db_Exception
  * @return Comments_Model_CommentAlias
  */
 protected function decComments($count = 1)
 {
     $aliasManager = new Comments_Model_CommentAlias_Manager();
     $alias = $aliasManager->getDbTable()->find($this->aliasId)->current();
     if ($alias->isKeyRequired() && $alias->isRelatedTableDefined()) {
         $table = new Zend_Db_Table($alias->relatedTable);
         $row = $table->find($this->key)->current();
         if ($row) {
             $row->comments -= $count;
             $row->save();
         } else {
             throw new Zend_Db_Exception('Row not found');
         }
     }
     return $this;
 }