1
0
mirror of synced 2025-02-21 22:53:15 +03:00
This commit is contained in:
zYne 2007-06-24 22:23:53 +00:00
parent 0d5b4493c3
commit ab1f1de913
2 changed files with 111 additions and 88 deletions

View File

@ -145,6 +145,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$record->preSave($event);
if ( ! $event->getSkipOperation()) {
switch ($record->state()) {
case Doctrine_Record::STATE_TDIRTY:
$this->insert($record);
@ -158,6 +159,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
// do nothing
break;
}
}
$record->postSave($event);
@ -186,13 +188,14 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$this->deleteComposites($record);
if ( ! $event->getSkipOperation()) {
$this->conn->transaction->addDelete($record);
$record->postDelete($event);
$record->state(Doctrine_Record::STATE_TCLEAN);
}
$record->getTable()->getListener()->onDelete($record);
$record->state(Doctrine_Record::STATE_TCLEAN);
$record->postDelete($event);
$this->conn->commit();
@ -337,6 +340,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$record->preUpdate($event);
if ( ! $event->getSkipOperation()) {
$array = $record->getPrepared();
if (empty($array)) {
@ -373,7 +377,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$stmt->execute($params);
$record->assignIdentifier(true);
}
$record->postUpdate($event);
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onUpdate($record);
@ -395,6 +399,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$record->preInsert($event);
if ( ! $event->getSkipOperation()) {
$array = $record->getPrepared();
if (empty($array)) {
@ -432,7 +437,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
} else {
$record->assignIdentifier(true);
}
}
$record->postInsert($event);
// listen the onInsert event

View File

@ -137,6 +137,24 @@ class Doctrine_Event
{
return $this->_code;
}
/**
* setSkipOperation
*
* @return void
*/
public function setSkipOperation($bool)
{
$this->_skipOperation = (bool) $bool;
}
/**
* getSkipOperation
*
* @return void
*/
public function getSkipOperation()
{
return $this->_skipOperation;
}
/**
* start
* starts the internal timer of this event