Commit 782cbe37 authored by zYne's avatar zYne

new template methods

parent e057ab7d
......@@ -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);
......
......@@ -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
*
......
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