1
0
mirror of synced 2024-12-14 07:06:04 +03:00

new template methods

This commit is contained in:
zYne 2007-06-24 21:37:19 +00:00
parent e057ab7d77
commit 782cbe37f8
2 changed files with 73 additions and 5 deletions

View File

@ -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);
@ -154,6 +156,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
// do nothing
break;
}
$record->postSave();
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record);
}
@ -173,11 +177,15 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$this->conn->beginTransaction();
$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);
@ -320,6 +328,8 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
public function update(Doctrine_Record $record)
{
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onPreUpdate($record);
$record->preUpdate();
$array = $record->getPrepared();
@ -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;
@ -372,6 +384,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();
@ -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);

View File

@ -275,21 +275,73 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* validations that are neccessary.
*/
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
*