Commit a593d746 authored by zYne's avatar zYne

--no commit message

--no commit message
parent dea4968a
...@@ -78,6 +78,22 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface ...@@ -78,6 +78,22 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
public function postTransactionBegin(Doctrine_Event $event) public function postTransactionBegin(Doctrine_Event $event)
{ } { }
public function preSavepointCommit(Doctrine_Event $event)
{ }
public function postSavepointCommit(Doctrine_Event $event)
{ }
public function preSavepointRollback(Doctrine_Event $event)
{ }
public function postSavepointRollback(Doctrine_Event $event)
{ }
public function preSavepointCreate(Doctrine_Event $event)
{ }
public function postSavepointCreate(Doctrine_Event $event)
{ }
public function postConnect(Doctrine_Event $event) public function postConnect(Doctrine_Event $event)
{ } { }
public function preConnect(Doctrine_Event $event) public function preConnect(Doctrine_Event $event)
......
...@@ -214,25 +214,36 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -214,25 +214,36 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
{ {
$this->conn->connect(); $this->conn->connect();
$listener = $this->conn->getAttribute(Doctrine::ATTR_LISTENER);
if ( ! is_null($savepoint)) { if ( ! is_null($savepoint)) {
$this->beginTransaction(); $this->beginTransaction();
$this->savePoints[] = $savepoint; $this->savePoints[] = $savepoint;
$event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_CREATE);
$listener->preSavepointCreate($event);
if ( ! $event->skipOperation) {
$this->createSavePoint($savepoint); $this->createSavePoint($savepoint);
}
$listener->postSavepointCreate($event);
} else { } else {
if ($this->transactionLevel == 0) { if ($this->transactionLevel == 0) {
$event = new Doctrine_Event($this, Doctrine_Event::TX_BEGIN); $event = new Doctrine_Event($this, Doctrine_Event::TX_BEGIN);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionBegin($event); $listener->preTransactionBegin($event);
if ( ! $event->skipOperation) {
try { try {
$this->conn->getDbh()->beginTransaction(); $this->conn->getDbh()->beginTransaction();
} catch(Exception $e) { } catch(Exception $e) {
throw new Doctrine_Transaction_Exception($e->getMessage()); throw new Doctrine_Transaction_Exception($e->getMessage());
} }
}
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionBegin($event); $listener->postTransactionBegin($event);
} }
} }
...@@ -261,15 +272,25 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -261,15 +272,25 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
return false; return false;
} }
$listener = $this->conn->getAttribute(Doctrine::ATTR_LISTENER);
if ( ! is_null($savepoint)) { if ( ! is_null($savepoint)) {
$this->transactionLevel = $this->removeSavePoints($savepoint); $this->transactionLevel = $this->removeSavePoints($savepoint);
$event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_COMMIT);
$listener->preSavepointCommit($event);
if ( ! $event->skipOperation) {
$this->releaseSavePoint($savepoint); $this->releaseSavePoint($savepoint);
}
$listener->postSavepointCommit($event);
} else { } else {
if ($this->transactionLevel == 1) { if ($this->transactionLevel == 1) {
$event = new Doctrine_Event($this, Doctrine_Event::TX_COMMIT); $event = new Doctrine_Event($this, Doctrine_Event::TX_COMMIT);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionCommit($event); $listener->preTransactionCommit($event);
if ( ! $event->skipOperation) { if ( ! $event->skipOperation) {
try { try {
...@@ -300,7 +321,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -300,7 +321,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
//$this->conn->unitOfWork->reset(); //$this->conn->unitOfWork->reset();
} }
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionCommit($event); $listener->postTransactionCommit($event);
} }
} }
...@@ -330,20 +351,24 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -330,20 +351,24 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
return false; return false;
} }
$listener = $this->conn->getAttribute(Doctrine::ATTR_LISTENER);
if ( ! is_null($savepoint)) { if ( ! is_null($savepoint)) {
$this->transactionLevel = $this->removeSavePoints($savepoint); $this->transactionLevel = $this->removeSavePoints($savepoint);
$event = new Doctrine_Event($this, Doctrine_Event::ROLLBACK_SAVEPOINT); $event = new Doctrine_Event($this, Doctrine_Event::SAVEPOINT_ROLLBACK);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preSavepointRollback($event); $listener->preSavepointRollback($event);
if ( ! $event->skipOperation) {
$this->rollbackSavePoint($savepoint); $this->rollbackSavePoint($savepoint);
}
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postSavepointRollback($event); $listener->postSavepointRollback($event);
} else { } else {
$event = new Doctrine_Event($this, Doctrine_Event::TX_ROLLBACK); $event = new Doctrine_Event($this, Doctrine_Event::TX_ROLLBACK);
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionRollback($event); $listener->preTransactionRollback($event);
if ( ! $event->skipOperation) { if ( ! $event->skipOperation) {
$this->deteles = array(); $this->deteles = array();
...@@ -356,7 +381,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module ...@@ -356,7 +381,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
} }
} }
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionRollback($event); $listener->postTransactionRollback($event);
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment