EventListener method names updated
This commit is contained in:
parent
628aac0ef4
commit
e1fbae22a4
@ -64,10 +64,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
* keys representing Doctrine_Table component names and values as Doctrine_Table objects
|
* keys representing Doctrine_Table component names and values as Doctrine_Table objects
|
||||||
*/
|
*/
|
||||||
protected $tables = array();
|
protected $tables = array();
|
||||||
/**
|
|
||||||
* @var array $exported
|
|
||||||
*/
|
|
||||||
protected $exported = array();
|
|
||||||
/**
|
/**
|
||||||
* @var string $driverName the name of this connection driver
|
* @var string $driverName the name of this connection driver
|
||||||
*/
|
*/
|
||||||
@ -331,7 +327,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::CONNECT);
|
$event = new Doctrine_Event($this, Doctrine_Event::CONNECT);
|
||||||
|
|
||||||
$this->getListener()->onPreConnect($event);
|
$this->getListener()->preConnect($event);
|
||||||
|
|
||||||
$e = explode(':', $this->options['dsn']);
|
$e = explode(':', $this->options['dsn']);
|
||||||
$found = false;
|
$found = false;
|
||||||
@ -365,7 +361,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
|
|
||||||
$this->isConnected = true;
|
$this->isConnected = true;
|
||||||
|
|
||||||
$this->getListener()->onConnect($event);
|
$this->getListener()->postConnect($event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -676,13 +672,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
{
|
{
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Db_Event::PREPARE, $statement);
|
$event = new Doctrine_Event($this, Doctrine_Event::PREPARE, $statement);
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onPrePrepare($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->prePrepare($event);
|
||||||
|
|
||||||
|
$stmt = false;
|
||||||
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
$stmt = $this->dbh->prepare($statement);
|
$stmt = $this->dbh->prepare($statement);
|
||||||
|
}
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onPrepare($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->postPrepare($event);
|
||||||
|
|
||||||
return new Doctrine_Connection_Statement($this, $stmt);
|
return new Doctrine_Connection_Statement($this, $stmt);
|
||||||
}
|
}
|
||||||
@ -760,15 +760,16 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
return $stmt;
|
return $stmt;
|
||||||
} else {
|
} else {
|
||||||
$event = new Doctrine_Event($this, Doctrine_EVENT::QUERY, $query, $params);
|
$event = new Doctrine_Event($this, Doctrine_Event::QUERY, $query, $params);
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onPreQuery($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event);
|
||||||
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
$stmt = $this->dbh->query($query);
|
$stmt = $this->dbh->query($query);
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onQuery($event);
|
|
||||||
|
|
||||||
$this->_count++;
|
$this->_count++;
|
||||||
|
}
|
||||||
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event);
|
||||||
|
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
@ -796,13 +797,14 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
} else {
|
} else {
|
||||||
$event = new Doctrine_Event($this, Doctrine_EVENT::EXEC, $query, $params);
|
$event = new Doctrine_Event($this, Doctrine_EVENT::EXEC, $query, $params);
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onPreExec($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->preExec($event);
|
||||||
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
$count = $this->dbh->exec($query);
|
$count = $this->dbh->exec($query);
|
||||||
|
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->onExec($event);
|
|
||||||
|
|
||||||
$this->_count++;
|
$this->_count++;
|
||||||
|
}
|
||||||
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->postExec($event);
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,8 @@ class Doctrine_Connection_Profiler implements Doctrine_Overloadable, IteratorAgg
|
|||||||
throw new Doctrine_Connection_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Event.");
|
throw new Doctrine_Connection_Profiler_Exception("Couldn't listen event. Event should be an instance of Doctrine_Event.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// event methods should start with 'on'
|
|
||||||
if (substr($m, 0, 2) !== 'on') {
|
|
||||||
throw new Doctrine_Connection_Profiler_Exception("Couldn't invoke listener :" . $m);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (substr($m, 2, 3) === 'Pre' && substr($m, 2, 7) !== 'Prepare') {
|
if (substr($m, 0, 3) === 'pre') {
|
||||||
// pre-event listener found
|
// pre-event listener found
|
||||||
$a[0]->start();
|
$a[0]->start();
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
|
|||||||
* statement holds an instance of Doctrine_Connection
|
* statement holds an instance of Doctrine_Connection
|
||||||
*/
|
*/
|
||||||
protected $_conn;
|
protected $_conn;
|
||||||
|
/**
|
||||||
|
* @var mixed $_stmt PDOStatement object, boolean false or Doctrine_Adapter_Statement object
|
||||||
|
*/
|
||||||
protected $_stmt;
|
protected $_stmt;
|
||||||
|
|
||||||
protected $_executed = false;
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
@ -54,7 +54,7 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
|
|||||||
$this->_stmt = $stmt;
|
$this->_stmt = $stmt;
|
||||||
|
|
||||||
if ($stmt === false) {
|
if ($stmt === false) {
|
||||||
throw new Doctrine_Db_Exception('Unknown statement object given.');
|
throw new Doctrine_Exception('Unknown statement object given.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -215,14 +215,14 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
|
|||||||
{
|
{
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::EXECUTE, $this->_stmt->queryString, $params);
|
$event = new Doctrine_Event($this, Doctrine_Event::EXECUTE, $this->_stmt->queryString, $params);
|
||||||
// print $this->_stmt->queryString . print_r($params, true) . "<br>";
|
// print $this->_stmt->queryString . print_r($params, true) . "<br>";
|
||||||
$skip = $this->_conn->getListener()->onPreExecute($event);
|
$this->_conn->getListener()->preExecute($event);
|
||||||
|
|
||||||
if ( ! $skip) {
|
if ( ! $event->skipOperation) {
|
||||||
$this->_stmt->execute($params);
|
$this->_stmt->execute($params);
|
||||||
$this->_conn->incrementQueryCount();
|
$this->_conn->incrementQueryCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_conn->getListener()->onExecute($event);
|
$this->_conn->getListener()->postExecute($event);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -253,20 +253,23 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function fetch($fetchStyle = Doctrine::FETCH_BOTH,
|
public function fetch($fetchMode = Doctrine::FETCH_BOTH,
|
||||||
$cursorOrientation = Doctrine::FETCH_ORI_NEXT,
|
$cursorOrientation = Doctrine::FETCH_ORI_NEXT,
|
||||||
$cursorOffset = null)
|
$cursorOffset = null)
|
||||||
{
|
{
|
||||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::FETCHALL, $this->_stmt->getQuery(),
|
$event = new Doctrine_Db_Event($this, Doctrine_Event::FETCHALL, $this->_stmt->getQuery());
|
||||||
array($fetchStyle, $cursorOrientation, $cursorOffset));
|
|
||||||
|
|
||||||
$data = $this->_conn->getListener()->onPreFetch($event);
|
$event->fetchMode = $fetchMode;
|
||||||
|
$event->cursorOrientation = $cursorOrientation;
|
||||||
|
$event->cursorOffset = $cursorOffset;
|
||||||
|
|
||||||
if ($data === null) {
|
$data = $this->_conn->getListener()->preFetch($event);
|
||||||
$data = $this->_stmt->fetch($fetchStyle, $cursorOrientation, $cursorOffset);
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
|
$data = $this->_stmt->fetch($fetchMode, $cursorOrientation, $cursorOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_conn->getListener()->onFetch($event);
|
$this->_conn->getListener()->postFetch($event);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -274,29 +277,35 @@ class Doctrine_Connection_Statement implements Doctrine_Adapter_Statement_Interf
|
|||||||
* fetchAll
|
* fetchAll
|
||||||
* Returns an array containing all of the result set rows
|
* Returns an array containing all of the result set rows
|
||||||
*
|
*
|
||||||
*
|
* @param integer $fetchMode Controls how the next row will be returned to the caller.
|
||||||
|
* This value must be one of the Doctrine::FETCH_* constants,
|
||||||
|
* defaulting to Doctrine::FETCH_BOTH
|
||||||
*
|
*
|
||||||
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
|
* @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
|
||||||
* Doctrine::FETCH_COLUMN. Defaults to 0.
|
* Doctrine::FETCH_COLUMN. Defaults to 0.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchAll($fetchStyle = Doctrine::FETCH_BOTH,
|
public function fetchAll($fetchMode = Doctrine::FETCH_BOTH,
|
||||||
$columnIndex = null)
|
$columnIndex = null)
|
||||||
{
|
{
|
||||||
$event = new Doctrine_Db_Event($this, Doctrine_Db_Event::FETCHALL, $this->_stmt->getQuery(), array($fetchStyle, $columnIndex));
|
$event = new Doctrine_Db_Event($this, Doctrine_Event::FETCHALL, $this->_stmt->getQuery());
|
||||||
|
$event->fetchMode = $fetchMode;
|
||||||
|
$event->columnIndex = $columnIndex;
|
||||||
|
|
||||||
$data = $this->_conn->getListener()->onPreFetchAll($event);
|
$this->_conn->getListener()->preFetchAll($event);
|
||||||
|
|
||||||
if ($data === null) {
|
if ( ! $event->skipOperation) {
|
||||||
if ($columnIndex !== null) {
|
if ($columnIndex !== null) {
|
||||||
$data = $this->_stmt->fetchAll($fetchStyle, $columnIndex);
|
$data = $this->_stmt->fetchAll($fetchMode, $columnIndex);
|
||||||
} else {
|
} else {
|
||||||
$data = $this->_stmt->fetchAll($fetchStyle);
|
$data = $this->_stmt->fetchAll($fetchMode);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_conn->getListener()->onFetchAll($event);
|
$event->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_conn->getListener()->postFetchAll($event);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
@ -139,13 +139,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
*/
|
*/
|
||||||
public function save(Doctrine_Record $record)
|
public function save(Doctrine_Record $record)
|
||||||
{
|
{
|
||||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record);
|
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::SAVE);
|
$event = new Doctrine_Event($this, Doctrine_Event::SAVE);
|
||||||
|
|
||||||
$record->preSave($event);
|
$record->preSave($event);
|
||||||
|
|
||||||
if ( ! $event->getOption('skipOperation')) {
|
if ( ! $event->skipOperation) {
|
||||||
switch ($record->state()) {
|
switch ($record->state()) {
|
||||||
case Doctrine_Record::STATE_TDIRTY:
|
case Doctrine_Record::STATE_TDIRTY:
|
||||||
$this->insert($record);
|
$this->insert($record);
|
||||||
@ -162,8 +160,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
$record->postSave($event);
|
$record->postSave($event);
|
||||||
|
|
||||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* deletes this data access object and all the related composites
|
* deletes this data access object and all the related composites
|
||||||
@ -180,21 +176,17 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
}
|
}
|
||||||
$this->conn->beginTransaction();
|
$this->conn->beginTransaction();
|
||||||
|
|
||||||
$record->getTable()->getListener()->onPreDelete($record);
|
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::DELETE);
|
$event = new Doctrine_Event($this, Doctrine_Event::DELETE);
|
||||||
|
|
||||||
$record->preDelete($event);
|
$record->preDelete($event);
|
||||||
|
|
||||||
$this->deleteComposites($record);
|
$this->deleteComposites($record);
|
||||||
|
|
||||||
if ( ! $event->getOption('skipOperation')) {
|
if ( ! $event->skipOperation) {
|
||||||
$this->conn->transaction->addDelete($record);
|
$this->conn->transaction->addDelete($record);
|
||||||
|
|
||||||
$record->state(Doctrine_Record::STATE_TCLEAN);
|
$record->state(Doctrine_Record::STATE_TCLEAN);
|
||||||
}
|
}
|
||||||
$record->getTable()->getListener()->onDelete($record);
|
|
||||||
|
|
||||||
$record->postDelete($event);
|
$record->postDelete($event);
|
||||||
|
|
||||||
$this->conn->commit();
|
$this->conn->commit();
|
||||||
@ -334,13 +326,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
*/
|
*/
|
||||||
public function update(Doctrine_Record $record)
|
public function update(Doctrine_Record $record)
|
||||||
{
|
{
|
||||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreUpdate($record);
|
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::UPDATE);
|
$event = new Doctrine_Event($this, Doctrine_Event::UPDATE);
|
||||||
|
|
||||||
$record->preUpdate($event);
|
$record->preUpdate($event);
|
||||||
|
|
||||||
if ( ! $event->getOption('skipOperation')) {
|
if ( ! $event->skipOperation) {
|
||||||
$array = $record->getPrepared();
|
$array = $record->getPrepared();
|
||||||
|
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
@ -380,8 +370,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
}
|
}
|
||||||
$record->postUpdate($event);
|
$record->postUpdate($event);
|
||||||
|
|
||||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onUpdate($record);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -393,13 +381,11 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
public function insert(Doctrine_Record $record)
|
public function insert(Doctrine_Record $record)
|
||||||
{
|
{
|
||||||
// listen the onPreInsert event
|
// listen the onPreInsert event
|
||||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreInsert($record);
|
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::INSERT);
|
$event = new Doctrine_Event($this, Doctrine_Event::INSERT);
|
||||||
|
|
||||||
$record->preInsert($event);
|
$record->preInsert($event);
|
||||||
|
|
||||||
if ( ! $event->getOption('skipOperation')) {
|
if ( ! $event->skipOperation) {
|
||||||
$array = $record->getPrepared();
|
$array = $record->getPrepared();
|
||||||
|
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
@ -440,9 +426,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
}
|
}
|
||||||
$record->postInsert($event);
|
$record->postInsert($event);
|
||||||
|
|
||||||
// listen the onInsert event
|
|
||||||
$table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ class Doctrine_Event
|
|||||||
* @param string $option the name of the option
|
* @param string $option the name of the option
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getOption($option)
|
public function __get($option)
|
||||||
{
|
{
|
||||||
if ( ! isset($this->_options[$option])) {
|
if ( ! isset($this->_options[$option])) {
|
||||||
return null;
|
return null;
|
||||||
@ -155,13 +155,15 @@ class Doctrine_Event
|
|||||||
/**
|
/**
|
||||||
* skipOperation
|
* skipOperation
|
||||||
* skips the next operation
|
* skips the next operation
|
||||||
* an alias for setOption('skipOperation', true)
|
* an alias for __set('skipOperation', true)
|
||||||
*
|
*
|
||||||
* @return Doctrine_Event this object
|
* @return Doctrine_Event this object
|
||||||
*/
|
*/
|
||||||
public function skipOperation()
|
public function skipOperation()
|
||||||
{
|
{
|
||||||
return $this->setOption('skipOperation', true);
|
$this->_options['skipOperation'] = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* setOption
|
* setOption
|
||||||
@ -171,7 +173,7 @@ class Doctrine_Event
|
|||||||
* @param mixed $value the value of the given option
|
* @param mixed $value the value of the given option
|
||||||
* @return Doctrine_Event this object
|
* @return Doctrine_Event this object
|
||||||
*/
|
*/
|
||||||
public function setOption($option, $value)
|
public function __set($option, $value)
|
||||||
{
|
{
|
||||||
$this->_options[$option] = $value;
|
$this->_options[$option] = $value;
|
||||||
|
|
||||||
|
@ -45,31 +45,6 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
|
|||||||
public function onWakeUp(Doctrine_Record $record)
|
public function onWakeUp(Doctrine_Record $record)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onUpdate(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
public function onPreUpdate(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public function onCreate(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
public function onPreCreate(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public function onSave(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
public function onPreSave(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public function onInsert(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
public function onPreInsert(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public function onDelete(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
public function onPreDelete(Doctrine_Record $record)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
public function onEvict(Doctrine_Record $record)
|
public function onEvict(Doctrine_Record $record)
|
||||||
{ }
|
{ }
|
||||||
public function onPreEvict(Doctrine_Record $record)
|
public function onPreEvict(Doctrine_Record $record)
|
||||||
@ -88,56 +63,53 @@ class Doctrine_EventListener implements Doctrine_EventListener_Interface
|
|||||||
public function onOpen(Doctrine_Connection $connection)
|
public function onOpen(Doctrine_Connection $connection)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
public function preTransactionCommit(Doctrine_Event $event)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onTransactionCommit(Doctrine_Event $event)
|
|
||||||
{ }
|
{ }
|
||||||
public function onPreTransactionCommit(Doctrine_Event $event)
|
public function postTransactionCommit(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onTransactionRollback(Doctrine_Event $event)
|
public function preTransactionRollback(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onPreTransactionRollback(Doctrine_Event $event)
|
public function postTransactionRollback(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onTransactionBegin(Doctrine_Event $event)
|
public function preTransactionBegin(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onPreTransactionBegin(Doctrine_Event $event)
|
public function postTransactionBegin(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onConnect(Doctrine_Event $event)
|
public function postConnect(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onPreConnect(Doctrine_Event $event)
|
public function preConnect(Doctrine_Event $event)
|
||||||
{ }
|
|
||||||
public function onPreQuery(Doctrine_Event $event)
|
|
||||||
{ }
|
|
||||||
public function onQuery(Doctrine_Event $event)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onPrePrepare(Doctrine_Event $event)
|
public function preQuery(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onPrepare(Doctrine_Event $event)
|
public function postQuery(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onPreExec(Doctrine_Event $event)
|
public function prePrepare(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onExec(Doctrine_Event $event)
|
public function postPrepare(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onPreFetch(Doctrine_Event $event)
|
public function preExec(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onFetch(Doctrine_Event $event)
|
public function postExec(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onPreFetchAll(Doctrine_Event $event)
|
public function preFetch(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onFetchAll(Doctrine_Event $event)
|
public function postFetch(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public function onPreExecute(Doctrine_Event $event)
|
public function preFetchAll(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
public function onExecute(Doctrine_Event $event)
|
public function postFetchAll(Doctrine_Event $event)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public function preExecute(Doctrine_Event $event)
|
||||||
|
{ }
|
||||||
|
public function postExecute(Doctrine_Event $event)
|
||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
@ -138,163 +138,6 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
$listener->onWakeUp($record);
|
$listener->onWakeUp($record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* onUpdate
|
|
||||||
* an event invoked after Doctrine_Record is updated
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onUpdate(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onUpdate($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onPreUpdate
|
|
||||||
* an event invoked before Doctrine_Record is updated
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreUpdate(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreUpdate($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onCreate
|
|
||||||
* an event invoked when a new Doctrine_Record is created
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onCreate(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onCreate($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onPreCreate
|
|
||||||
* an event invoked when a new Doctrine_Record
|
|
||||||
* but not yet initialized
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreCreate(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreCreate($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onSave
|
|
||||||
* an event invoked after a Doctrine_Record is saved (inserted / updated)
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onSave(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onSave($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onSave
|
|
||||||
* an event invoked after a Doctrine_Record is saved (inserted / updated)
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreSave(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreSave($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onInsert
|
|
||||||
* an event invoked after Doctrine_Record is inserted into database
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onInsert(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onInsert($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onPreInsert
|
|
||||||
* an event invoked before Doctrine_Record is inserted into database
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreInsert(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreInsert($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onDelete
|
|
||||||
* an event invoked after Doctrine_Record is deleted from database
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onDelete(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onDelete($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onPreDelete
|
|
||||||
* an event invoked before Doctrine_Record is deleted from database
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreDelete(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreDelete($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onEvict
|
|
||||||
* an event invoked after Doctrine_Record is evicted from record repository
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onEvict(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onEvict($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* onPreEvict
|
|
||||||
* an event invoked before Doctrine_Record is evicted from record repository
|
|
||||||
*
|
|
||||||
* @param Doctrine_Record $record
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function onPreEvict(Doctrine_Record $record)
|
|
||||||
{
|
|
||||||
foreach ($this->listeners as $listener) {
|
|
||||||
$listener->onPreEvict($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* onClose
|
* onClose
|
||||||
* an event invoked after Doctrine_Connection is closed
|
* an event invoked after Doctrine_Connection is closed
|
||||||
@ -341,10 +184,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onTransactionCommit(Doctrine_Event $event)
|
public function postTransactionCommit(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onTransactionCommit($event);
|
$listener->postTransactionCommit($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -354,10 +197,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onPreTransactionCommit(Doctrine_Event $event)
|
public function preTransactionCommit(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreTransactionCommit($event);
|
$listener->preTransactionCommit($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -367,10 +210,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onTransactionRollback(Doctrine_Event $event)
|
public function postTransactionRollback(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onTransactionRollback($event);
|
$listener->postTransactionRollback($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -380,10 +223,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onPreTransactionRollback(Doctrine_Event $event)
|
public function preTransactionRollback(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreTransactionRollback($event);
|
$listener->preTransactionRollback($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -393,10 +236,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onTransactionBegin(Doctrine_Event $event)
|
public function postTransactionBegin(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onTransactionBegin($event);
|
$listener->postTransactionBegin($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -406,10 +249,10 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
* @param Doctrine_Event $event
|
* @param Doctrine_Event $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onPreTransactionBegin(Doctrine_Event $event)
|
public function preTransactionBegin(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreTransactionBegin($event);
|
$listener->preTransactionBegin($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -438,95 +281,95 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E
|
|||||||
$listener->onPreCollectionDelete($collection);
|
$listener->onPreCollectionDelete($collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onConnect(Doctrine_Event $event)
|
public function postConnect(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onConnect($event);
|
$listener->postConnect($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onPreConnect(Doctrine_Event $event)
|
public function preConnect(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreConnect($event);
|
$listener->preConnect($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onPreQuery(Doctrine_Event $event)
|
public function preQuery(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreQuery($event);
|
$listener->preQuery($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onQuery(Doctrine_Event $event)
|
public function postQuery(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onQuery($event);
|
$listener->postQuery($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPrePrepare(Doctrine_Event $event)
|
public function prePrepare(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPrePrepare($event);
|
$listener->prePrepare($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onPrepare(Doctrine_Event $event)
|
public function postPrepare(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPrepare($event);
|
$listener->postPrepare($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreExec(Doctrine_Event $event)
|
public function preExec(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreExec($event);
|
$listener->preExec($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onExec(Doctrine_Event $event)
|
public function postExec(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onExec($event);
|
$listener->postExec($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreFetch(Doctrine_Event $event)
|
public function preFetch(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreFetch($event);
|
$listener->preFetch($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onFetch(Doctrine_Event $event)
|
public function postFetch(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onFetch($event);
|
$listener->postFetch($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreFetchAll(Doctrine_Event $event)
|
public function preFetchAll(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreFetchAll($event);
|
$listener->preFetchAll($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onFetchAll(Doctrine_Event $event)
|
public function postFetchAll(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onFetchAll($event);
|
$listener->postFetchAll($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPreExecute(Doctrine_Event $event)
|
public function preExecute(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onPreExecute($event);
|
$listener->preExecute($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onExecute(Doctrine_Event $event)
|
public function postExecute(Doctrine_Event $event)
|
||||||
{
|
{
|
||||||
foreach ($this->listeners as $listener) {
|
foreach ($this->listeners as $listener) {
|
||||||
$listener->onExecute($event);
|
$listener->postExecute($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,67 +34,33 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
|
|||||||
*/
|
*/
|
||||||
interface Doctrine_EventListener_Interface
|
interface Doctrine_EventListener_Interface
|
||||||
{
|
{
|
||||||
public function onLoad(Doctrine_Record $record);
|
public function preTransactionCommit(Doctrine_Event $event);
|
||||||
public function onPreLoad(Doctrine_Record $record);
|
public function postTransactionCommit(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onSleep(Doctrine_Record $record);
|
public function preTransactionRollback(Doctrine_Event $event);
|
||||||
public function onWakeUp(Doctrine_Record $record);
|
public function postTransactionRollback(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onUpdate(Doctrine_Record $record);
|
public function preTransactionBegin(Doctrine_Event $event);
|
||||||
public function onPreUpdate(Doctrine_Record $record);
|
public function postTransactionBegin(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onCreate(Doctrine_Record $record);
|
public function postConnect(Doctrine_Event $event);
|
||||||
public function onPreCreate(Doctrine_Record $record);
|
public function preConnect(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onSave(Doctrine_Record $record);
|
public function preQuery(Doctrine_Event $event);
|
||||||
public function onPreSave(Doctrine_Record $record);
|
public function postQuery(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onInsert(Doctrine_Record $record);
|
public function prePrepare(Doctrine_Event $event);
|
||||||
public function onPreInsert(Doctrine_Record $record);
|
public function postPrepare(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onDelete(Doctrine_Record $record);
|
public function preExec(Doctrine_Event $event);
|
||||||
public function onPreDelete(Doctrine_Record $record);
|
public function postExec(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onEvict(Doctrine_Record $record);
|
public function preFetch(Doctrine_Event $event);
|
||||||
public function onPreEvict(Doctrine_Record $record);
|
public function postFetch(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onClose(Doctrine_Event $event);
|
public function preFetchAll(Doctrine_Event $event);
|
||||||
public function onPreClose(Doctrine_Event $event);
|
public function postFetchAll(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onCollectionDelete(Doctrine_Collection $collection);
|
public function preExecute(Doctrine_Event $event);
|
||||||
public function onPreCollectionDelete(Doctrine_Collection $collection);
|
public function postExecute(Doctrine_Event $event);
|
||||||
|
|
||||||
public function onOpen(Doctrine_Connection $connection);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function onConnect(Doctrine_Event $event);
|
|
||||||
public function onPreConnect(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onTransactionCommit(Doctrine_Event $event);
|
|
||||||
public function onPreTransactionCommit(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onTransactionRollback(Doctrine_Event $event);
|
|
||||||
public function onPreTransactionRollback(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onTransactionBegin(Doctrine_Event $event);
|
|
||||||
public function onPreTransactionBegin(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPreQuery(Doctrine_Event $event);
|
|
||||||
public function onQuery(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPrePrepare(Doctrine_Event $event);
|
|
||||||
public function onPrepare(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPreExec(Doctrine_Event $event);
|
|
||||||
public function onExec(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPreFetch(Doctrine_Event $event);
|
|
||||||
public function onFetch(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPreFetchAll(Doctrine_Event $event);
|
|
||||||
public function onFetchAll(Doctrine_Event $event);
|
|
||||||
|
|
||||||
public function onPreExecute(Doctrine_Event $event);
|
|
||||||
public function onExecute(Doctrine_Event $event);
|
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
|
|||||||
case 'mock':
|
case 'mock':
|
||||||
case 'oracle':
|
case 'oracle':
|
||||||
if ( ! isset($parts['path']) || $parts['path'] == '/') {
|
if ( ! isset($parts['path']) || $parts['path'] == '/') {
|
||||||
throw new Doctrine_Db_Exception('No database availible in data source name');
|
throw new Doctrine_Manager_Exception('No database availible in data source name');
|
||||||
}
|
}
|
||||||
if (isset($parts['path'])) {
|
if (isset($parts['path'])) {
|
||||||
$parts['database'] = substr($parts['path'], 1);
|
$parts['database'] = substr($parts['path'], 1);
|
||||||
@ -345,7 +345,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Doctrine_Db_Exception('Unknown driver '.$parts['scheme']);
|
throw new Doctrine_Manager_Exception('Unknown driver '.$parts['scheme']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,14 +157,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
|
|
||||||
$keys = $this->_table->getPrimaryKeys();
|
$keys = $this->_table->getPrimaryKeys();
|
||||||
|
|
||||||
if ( ! $exists) {
|
|
||||||
// listen the onPreCreate event
|
|
||||||
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onPreCreate($this);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// listen the onPreLoad event
|
|
||||||
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onPreLoad($this);
|
|
||||||
}
|
|
||||||
// get the data array
|
// get the data array
|
||||||
$this->_data = $this->_table->getData();
|
$this->_data = $this->_table->getData();
|
||||||
|
|
||||||
@ -185,19 +177,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
|
|
||||||
// set the default values for this record
|
// set the default values for this record
|
||||||
$this->assignDefaultValues();
|
$this->assignDefaultValues();
|
||||||
|
|
||||||
// listen the onCreate event
|
|
||||||
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onCreate($this);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||||
|
|
||||||
if ($count < $this->_table->getColumnCount()) {
|
if ($count < $this->_table->getColumnCount()) {
|
||||||
$this->_state = Doctrine_Record::STATE_PROXY;
|
$this->_state = Doctrine_Record::STATE_PROXY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// listen the onLoad event
|
|
||||||
$this->_table->getAttribute(Doctrine::ATTR_LISTENER)->onLoad($this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_errorStack = new Doctrine_Validator_ErrorStack();
|
$this->_errorStack = new Doctrine_Validator_ErrorStack();
|
||||||
|
@ -224,7 +224,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
if ($this->transactionLevel == 0) {
|
if ($this->transactionLevel == 0) {
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::BEGIN);
|
$event = new Doctrine_Event($this, Doctrine_Event::BEGIN);
|
||||||
|
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onPreTransactionBegin($event);
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionBegin($event);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->conn->getDbh()->beginTransaction();
|
$this->conn->getDbh()->beginTransaction();
|
||||||
@ -232,7 +232,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
throw new Doctrine_Transaction_Exception($e->getMessage());
|
throw new Doctrine_Transaction_Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onTransactionBegin($event);
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionBegin($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
* progress or release a savepoint. This function may only be called when
|
* progress or release a savepoint. This function may only be called when
|
||||||
* auto-committing is disabled, otherwise it will fail.
|
* auto-committing is disabled, otherwise it will fail.
|
||||||
*
|
*
|
||||||
* Listeners: onPreTransactionCommit, onTransactionCommit
|
* Listeners: preTransactionCommit, postTransactionCommit
|
||||||
*
|
*
|
||||||
* @param string $savepoint name of a savepoint to release
|
* @param string $savepoint name of a savepoint to release
|
||||||
* @throws Doctrine_Transaction_Exception if the transaction fails at database level
|
* @throws Doctrine_Transaction_Exception if the transaction fails at database level
|
||||||
@ -268,8 +268,10 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
} else {
|
} else {
|
||||||
if ($this->transactionLevel == 1) {
|
if ($this->transactionLevel == 1) {
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::COMMIT);
|
$event = new Doctrine_Event($this, Doctrine_Event::COMMIT);
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onPreTransactionCommit($event);
|
|
||||||
|
|
||||||
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionCommit($event);
|
||||||
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
try {
|
try {
|
||||||
$this->bulkDelete();
|
$this->bulkDelete();
|
||||||
|
|
||||||
@ -296,8 +298,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
$this->conn->getDbh()->commit();
|
$this->conn->getDbh()->commit();
|
||||||
|
|
||||||
//$this->conn->unitOfWork->reset();
|
//$this->conn->unitOfWork->reset();
|
||||||
|
}
|
||||||
|
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onTransactionCommit($event);
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionCommit($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,16 +330,16 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = new Doctrine_Event($this, Doctrine_Event::ROLLBACK);
|
|
||||||
|
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onPreTransactionRollback($event);
|
|
||||||
|
|
||||||
if ( ! is_null($savepoint)) {
|
if ( ! is_null($savepoint)) {
|
||||||
$this->transactionLevel = $this->removeSavePoints($savepoint);
|
$this->transactionLevel = $this->removeSavePoints($savepoint);
|
||||||
|
|
||||||
$this->rollbackSavePoint($savepoint);
|
$this->rollbackSavePoint($savepoint);
|
||||||
} else {
|
} else {
|
||||||
//$this->conn->unitOfWork->reset();
|
$event = new Doctrine_Event($this, Doctrine_Event::ROLLBACK);
|
||||||
|
|
||||||
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->preTransactionRollback($event);
|
||||||
|
|
||||||
|
if ( ! $event->skipOperation) {
|
||||||
$this->deteles = array();
|
$this->deteles = array();
|
||||||
|
|
||||||
$this->transactionLevel = 0;
|
$this->transactionLevel = 0;
|
||||||
@ -346,7 +349,9 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
|
|||||||
throw new Doctrine_Transaction_Exception($e->getMessage());
|
throw new Doctrine_Transaction_Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->onTransactionRollback($event);
|
|
||||||
|
$this->conn->getAttribute(Doctrine::ATTR_LISTENER)->postTransactionRollback($event);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
{}
|
{}
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public function testQuery()
|
public function testQuery()
|
||||||
{
|
{
|
||||||
$this->conn = Doctrine_Manager::getInstance()->openConnection(array('sqlite::memory:'));
|
$this->conn = Doctrine_Manager::getInstance()->openConnection(array('sqlite::memory:'));
|
||||||
@ -51,12 +52,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'CREATE TABLE test (id INT)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'CREATE TABLE test (id INT)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXEC);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXEC);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$this->assertEqual($this->conn->count(), 1);
|
$this->assertEqual($this->conn->count(), 1);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
public function testPrepareAndExecute()
|
public function testPrepareAndExecute()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -65,32 +66,32 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($event->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($event->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$stmt->execute(array(1));
|
$stmt->execute(array(1));
|
||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$this->assertEqual($this->conn->count(), 2);
|
$this->assertEqual($this->conn->count(), 2);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
public function testMultiplePrepareAndExecute()
|
public function testMultiplePrepareAndExecute()
|
||||||
{
|
{
|
||||||
|
|
||||||
$stmt = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
|
$stmt = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$stmt2 = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
|
$stmt2 = $this->conn->prepare('INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::PREPARE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::PREPARE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
/** TODO: strange errors here
|
/** TODO: strange errors here
|
||||||
$stmt->execute(array(1));
|
$stmt->execute(array(1));
|
||||||
@ -98,7 +99,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$this->assertEqual($this->conn->count(), 4);
|
$this->assertEqual($this->conn->count(), 4);
|
||||||
@ -117,12 +118,12 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
}
|
}
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), 'INSERT INTO test (id) VALUES (?)');
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::EXECUTE);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::EXECUTE);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
}
|
}
|
||||||
public function testTransactionRollback()
|
public function testTransactionRollback()
|
||||||
@ -135,7 +136,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
}
|
}
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::BEGIN);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::BEGIN);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -147,7 +148,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::ROLLBACK);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::ROLLBACK);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
}
|
}
|
||||||
public function testTransactionCommit()
|
public function testTransactionCommit()
|
||||||
@ -160,7 +161,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
}
|
}
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::BEGIN);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::BEGIN);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -173,7 +174,7 @@ class Doctrine_Connection_Profiler_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
$this->assertEqual($this->profiler->lastEvent()->getQuery(), null);
|
||||||
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
$this->assertTrue($this->profiler->lastEvent()->hasEnded());
|
||||||
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Db_Event::COMMIT);
|
$this->assertEqual($this->profiler->lastEvent()->getCode(), Doctrine_Event::COMMIT);
|
||||||
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
$this->assertTrue(is_numeric($this->profiler->lastEvent()->getElapsedSecs()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,33 +110,33 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
|
|||||||
$listener = $this->dbh->getListener();
|
$listener = $this->dbh->getListener();
|
||||||
$stmt = $this->dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
$stmt = $this->dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onPrepare');
|
$this->assertEqual($listener->pop(), 'postPrepare');
|
||||||
$this->assertEqual($listener->pop(), 'onPrePrepare');
|
$this->assertEqual($listener->pop(), 'prePrepare');
|
||||||
|
|
||||||
$stmt->execute(array(1));
|
$stmt->execute(array(1));
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onExecute');
|
$this->assertEqual($listener->pop(), 'postExecute');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExecute');
|
$this->assertEqual($listener->pop(), 'preExecute');
|
||||||
|
|
||||||
$this->dbh->exec('DELETE FROM entity');
|
$this->dbh->exec('DELETE FROM entity');
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onExec');
|
$this->assertEqual($listener->pop(), 'postExec');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExec');
|
$this->assertEqual($listener->pop(), 'preExec');
|
||||||
|
|
||||||
$this->dbh->beginTransaction();
|
$this->dbh->beginTransaction();
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onTransactionBegin');
|
$this->assertEqual($listener->pop(), 'postTransactionBegin');
|
||||||
$this->assertEqual($listener->pop(), 'onPreTransactionBegin');
|
$this->assertEqual($listener->pop(), 'preTransactionBegin');
|
||||||
|
|
||||||
$this->dbh->exec('INSERT INTO entity (id) VALUES (1)');
|
$this->dbh->exec('INSERT INTO entity (id) VALUES (1)');
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onExec');
|
$this->assertEqual($listener->pop(), 'postExec');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExec');
|
$this->assertEqual($listener->pop(), 'preExec');
|
||||||
|
|
||||||
$this->dbh->commit();
|
$this->dbh->commit();
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onTransactionCommit');
|
$this->assertEqual($listener->pop(), 'postTransactionCommit');
|
||||||
$this->assertEqual($listener->pop(), 'onPreTransactionCommit');
|
$this->assertEqual($listener->pop(), 'preTransactionCommit');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -152,63 +152,66 @@ class Doctrine_Db_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$listener = $this->dbh->getListener()->get(0);
|
$listener = $this->dbh->getListener()->get(0);
|
||||||
$listener2 = $this->dbh->getListener()->get(1);
|
$listener2 = $this->dbh->getListener()->get(1);
|
||||||
$this->assertEqual($listener->pop(), 'onExec');
|
$this->assertEqual($listener->pop(), 'postExec');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExec');
|
$this->assertEqual($listener->pop(), 'preExec');
|
||||||
|
|
||||||
$this->assertEqual($listener2->pop(), 'onExec');
|
$this->assertEqual($listener2->pop(), 'postExec');
|
||||||
$this->assertEqual($listener2->pop(), 'onPreExec');
|
$this->assertEqual($listener2->pop(), 'preExec');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListeningPrepareEventsWithListenerChain()
|
public function testListeningPrepareEventsWithListenerChain()
|
||||||
{
|
{
|
||||||
|
|
||||||
$stmt = $this->dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
$stmt = $this->dbh->prepare('INSERT INTO entity (id) VALUES(?)');
|
||||||
$listener = $this->dbh->getListener()->get(0);
|
$listener = $this->dbh->getListener()->get(0);
|
||||||
$listener2 = $this->dbh->getListener()->get(1);
|
$listener2 = $this->dbh->getListener()->get(1);
|
||||||
$this->assertEqual($listener->pop(), 'onPrepare');
|
$this->assertEqual($listener->pop(), 'postPrepare');
|
||||||
$this->assertEqual($listener->pop(), 'onPrePrepare');
|
$this->assertEqual($listener->pop(), 'prePrepare');
|
||||||
|
|
||||||
$this->assertEqual($listener2->pop(), 'onPrepare');
|
$this->assertEqual($listener2->pop(), 'postPrepare');
|
||||||
$this->assertEqual($listener2->pop(), 'onPrePrepare');
|
$this->assertEqual($listener2->pop(), 'prePrepare');
|
||||||
|
|
||||||
$stmt->execute(array(1));
|
$stmt->execute(array(1));
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onExecute');
|
$this->assertEqual($listener->pop(), 'postExecute');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExecute');
|
$this->assertEqual($listener->pop(), 'preExecute');
|
||||||
|
|
||||||
$this->assertEqual($listener2->pop(), 'onExecute');
|
$this->assertEqual($listener2->pop(), 'postExecute');
|
||||||
$this->assertEqual($listener2->pop(), 'onPreExecute');
|
$this->assertEqual($listener2->pop(), 'preExecute');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListeningExecEventsWithListenerChain()
|
public function testListeningExecEventsWithListenerChain()
|
||||||
{
|
{
|
||||||
$this->dbh->exec('DELETE FROM entity');
|
$this->dbh->exec('DELETE FROM entity');
|
||||||
$listener = $this->dbh->getListener()->get(0);
|
$listener = $this->dbh->getListener()->get(0);
|
||||||
$listener2 = $this->dbh->getListener()->get(1);
|
$listener2 = $this->dbh->getListener()->get(1);
|
||||||
$this->assertEqual($listener->pop(), 'onExec');
|
$this->assertEqual($listener->pop(), 'postExec');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExec');
|
$this->assertEqual($listener->pop(), 'preExec');
|
||||||
|
|
||||||
$this->assertEqual($listener2->pop(), 'onExec');
|
$this->assertEqual($listener2->pop(), 'postExec');
|
||||||
$this->assertEqual($listener2->pop(), 'onPreExec');
|
$this->assertEqual($listener2->pop(), 'preExec');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testListeningTransactionEventsWithListenerChain()
|
public function testListeningTransactionEventsWithListenerChain()
|
||||||
{
|
{
|
||||||
$this->dbh->beginTransaction();
|
$this->dbh->beginTransaction();
|
||||||
$listener = $this->dbh->getListener()->get(0);
|
$listener = $this->dbh->getListener()->get(0);
|
||||||
$listener2 = $this->dbh->getListener()->get(1);
|
$listener2 = $this->dbh->getListener()->get(1);
|
||||||
$this->assertEqual($listener->pop(), 'onTransactionBegin');
|
$this->assertEqual($listener->pop(), 'postTransactionBegin');
|
||||||
$this->assertEqual($listener->pop(), 'onPreTransactionBegin');
|
$this->assertEqual($listener->pop(), 'preTransactionBegin');
|
||||||
|
|
||||||
$this->assertEqual($listener2->pop(), 'onTransactionBegin');
|
$this->assertEqual($listener2->pop(), 'postTransactionBegin');
|
||||||
$this->assertEqual($listener2->pop(), 'onPreTransactionBegin');
|
$this->assertEqual($listener2->pop(), 'preTransactionBegin');
|
||||||
|
|
||||||
$this->dbh->exec('INSERT INTO entity (id) VALUES (1)');
|
$this->dbh->exec('INSERT INTO entity (id) VALUES (1)');
|
||||||
|
|
||||||
$this->dbh->commit();
|
$this->dbh->commit();
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onTransactionCommit');
|
$this->assertEqual($listener->pop(), 'postTransactionCommit');
|
||||||
$this->assertEqual($listener->pop(), 'onPreTransactionCommit');
|
$this->assertEqual($listener->pop(), 'preTransactionCommit');
|
||||||
|
|
||||||
$this->assertEqual($listener->pop(), 'onExec');
|
$this->assertEqual($listener->pop(), 'postExec');
|
||||||
$this->assertEqual($listener->pop(), 'onPreExec');
|
$this->assertEqual($listener->pop(), 'preExec');
|
||||||
|
|
||||||
$this->dbh->exec('DROP TABLE entity');
|
$this->dbh->exec('DROP TABLE entity');
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
{ }
|
{ }
|
||||||
public function prepareTables()
|
public function prepareTables()
|
||||||
{
|
{
|
||||||
$this->tables = array('RecordHookTest');
|
$this->tables = array('RecordHookTest', 'SoftDeleteTest');
|
||||||
|
|
||||||
parent::prepareTables();
|
parent::prepareTables();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,41 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($r->pop(), 'postDelete');
|
$this->assertEqual($r->pop(), 'postDelete');
|
||||||
$this->assertEqual($r->pop(), 'preDelete');
|
$this->assertEqual($r->pop(), 'preDelete');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSoftDelete()
|
||||||
|
{
|
||||||
|
$r = new SoftDeleteTest();
|
||||||
|
$r->name = 'something';
|
||||||
|
$r->save();
|
||||||
|
|
||||||
|
$this->assertEqual($r->name, 'something');
|
||||||
|
$this->assertEqual($r->deleted, null);
|
||||||
|
$this->assertEqual($r->getState(), Doctrine_Record::STATE_CLEAN);
|
||||||
|
|
||||||
|
$r->delete();
|
||||||
|
|
||||||
|
$this->assertEqual($r->getState(), Doctrine_Record::STATE_CLEAN);
|
||||||
|
$this->assertEqual($r->deleted, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
class SoftDeleteTest extends Doctrine_Record
|
||||||
|
{
|
||||||
|
public function setTableDefinition()
|
||||||
|
{
|
||||||
|
$this->hasColumn('name', 'string', null, array('primary' => true));
|
||||||
|
$this->hasColumn('deleted', 'boolean', 1);
|
||||||
|
}
|
||||||
|
public function preDelete($event)
|
||||||
|
{
|
||||||
|
$event->skipOperation();
|
||||||
|
}
|
||||||
|
public function postDelete($event)
|
||||||
|
{
|
||||||
|
$this->deleted = true;
|
||||||
|
$this->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class RecordHookTest extends Doctrine_Record
|
class RecordHookTest extends Doctrine_Record
|
||||||
{
|
{
|
||||||
protected $_messages = array();
|
protected $_messages = array();
|
||||||
@ -87,35 +121,35 @@ class RecordHookTest extends Doctrine_Record
|
|||||||
{
|
{
|
||||||
$this->hasColumn('name', 'string', null, array('primary' => true));
|
$this->hasColumn('name', 'string', null, array('primary' => true));
|
||||||
}
|
}
|
||||||
public function preSave()
|
public function preSave($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function postSave()
|
public function postSave($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function preInsert()
|
public function preInsert($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function postInsert()
|
public function postInsert($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function preUpdate()
|
public function preUpdate($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function postUpdate()
|
public function postUpdate($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function preDelete()
|
public function preDelete($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
public function postDelete()
|
public function postDelete($event)
|
||||||
{
|
{
|
||||||
$this->_messages[] = __FUNCTION__;
|
$this->_messages[] = __FUNCTION__;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user