new template methods
This commit is contained in:
parent
e057ab7d77
commit
782cbe37f8
@ -141,6 +141,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
{
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreSave($record);
|
||||
|
||||
$record->preSave();
|
||||
|
||||
switch ($record->state()) {
|
||||
case Doctrine_Record::STATE_TDIRTY:
|
||||
$this->insert($record);
|
||||
@ -155,6 +157,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
break;
|
||||
}
|
||||
|
||||
$record->postSave();
|
||||
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record);
|
||||
}
|
||||
/**
|
||||
@ -174,10 +178,14 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
|
||||
$record->getTable()->getListener()->onPreDelete($record);
|
||||
|
||||
$record->preDelete();
|
||||
|
||||
$this->deleteComposites($record);
|
||||
|
||||
$this->conn->transaction->addDelete($record);
|
||||
|
||||
$record->postDelete();
|
||||
|
||||
$record->getTable()->getListener()->onDelete($record);
|
||||
|
||||
$record->state(Doctrine_Record::STATE_TCLEAN);
|
||||
@ -321,6 +329,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
{
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreUpdate($record);
|
||||
|
||||
$record->preUpdate();
|
||||
|
||||
$array = $record->getPrepared();
|
||||
|
||||
if (empty($array)) {
|
||||
@ -358,6 +368,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
|
||||
$record->assignIdentifier(true);
|
||||
|
||||
$record->postUpdate();
|
||||
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onUpdate($record);
|
||||
|
||||
return true;
|
||||
@ -373,6 +385,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
// listen the onPreInsert event
|
||||
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreInsert($record);
|
||||
|
||||
$record->preInsert();
|
||||
|
||||
$array = $record->getPrepared();
|
||||
|
||||
if (empty($array)) {
|
||||
@ -411,6 +425,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
||||
$record->assignIdentifier(true);
|
||||
}
|
||||
|
||||
$record->postInsert();
|
||||
|
||||
// listen the onInsert event
|
||||
$table->getAttribute(Doctrine::ATTR_LISTENER)->onInsert($record);
|
||||
|
||||
|
@ -277,19 +277,71 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
protected function validate()
|
||||
{ }
|
||||
/**
|
||||
* Empty tempalte method to provide concrete Record classes with the possibility
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the validation procedure only when the record is going to be
|
||||
* updated.
|
||||
*/
|
||||
protected function validateOnUpdate()
|
||||
{ }
|
||||
/**
|
||||
* Empty tempalte method to provide concrete Record classes with the possibility
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the validation procedure only when the record is going to be
|
||||
* inserted into the data store the first time.
|
||||
*/
|
||||
protected function validateOnInsert()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure.
|
||||
*/
|
||||
public function preSave()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure.
|
||||
*/
|
||||
public function postSave()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the deletion procedure.
|
||||
*/
|
||||
public function preDelete()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the deletion procedure.
|
||||
*/
|
||||
public function postDelete()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure only when the record is going to be
|
||||
* updated.
|
||||
*/
|
||||
public function preUpdate()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure only when the record is going to be
|
||||
* updated.
|
||||
*/
|
||||
public function postUpdate()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure only when the record is going to be
|
||||
* inserted into the data store the first time.
|
||||
*/
|
||||
public function preInsert()
|
||||
{ }
|
||||
/**
|
||||
* Empty template method to provide concrete Record classes with the possibility
|
||||
* to hook into the saving procedure only when the record is going to be
|
||||
* inserted into the data store the first time.
|
||||
*/
|
||||
public function postInsert()
|
||||
{ }
|
||||
/**
|
||||
* getErrorStack
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user