Beispiel #1
0
 /**
  * Pre delete event hook deletes all related versions
  * This will only delete version records if the auditLog is enabled
  *
  * @param   Doctrine_Event $event
  * @return  void
  */
 public function preDelete(Doctrine_Event $event)
 {
     if ($this->_auditLog->getOption('auditLog')) {
         $className = $this->_auditLog->getOption('className');
         $version = $this->_auditLog->getOption('version');
         $name = $version['alias'] === null ? $version['name'] : $version['alias'];
         $event->getInvoker()->set($name, null);
         if ($this->_auditLog->getOption('deleteVersions')) {
             $q = Doctrine_Core::getTable($className)->createQuery('obj')->delete();
             foreach ((array) $this->_auditLog->getOption('table')->getIdentifier() as $id) {
                 $conditions[] = 'obj.' . $id . ' = ?';
                 $values[] = $event->getInvoker()->get($id);
             }
             $rows = $q->where(implode(' AND ', $conditions))->execute($values);
         }
     }
 }
Beispiel #2
0
 /**
  * Get the next version number for the audit log
  *
  * @param Doctrine_Record $record 
  * @return integer $nextVersion
  */
 protected function _getNextVersion(Doctrine_Record $record)
 {
     if ($this->_auditLog->getOption('auditLog')) {
         return $this->_auditLog->getMaxVersion($record) + 1;
     }
 }