Add EVENT_DB_BEFORE_CREATE and EVENT_DB_BEFORE_UPDATE events in CRUD calls

This commit is contained in:
Eric Espie
2023-05-17 10:16:18 +02:00
parent 4038d4d925
commit 0188108a68
2 changed files with 8 additions and 8 deletions

View File

@@ -5877,7 +5877,7 @@ JS
$this->FireEvent(EVENT_DB_CHECK_TO_WRITE);
}
final protected function FireEventBeforeDatabaseCreate()
final protected function FireEventBeforeObjectCreate()
{
$this->FireEvent(EVENT_DB_BEFORE_CREATE);
}
@@ -5904,7 +5904,7 @@ JS
* @return void
* @throws \CoreException
*/
final protected function FireEventBeforeDatabaseUpdate()
final protected function FireEventBeforeObjectUpdate()
{
$this->FireEvent(EVENT_DB_BEFORE_UPDATE);
}

View File

@@ -3066,6 +3066,8 @@ abstract class DBObject implements iDisplay
$this->DoComputeValues();
$this->OnInsert();
$this->FireEventBeforeObjectCreate();
// If not automatically computed, then check that the key is given by the caller
if (!MetaModel::IsAutoIncrementKey($sRootClass)) {
if (empty($this->m_iKey)) {
@@ -3085,9 +3087,7 @@ abstract class DBObject implements iDisplay
}
$this->ComputeStopWatchesDeadline(true);
$this->FireEventBeforeDatabaseCreate();
$iTransactionRetry = 1;
$bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled');
if ($bIsTransactionEnabled) {
@@ -3278,7 +3278,7 @@ abstract class DBObject implements iDisplay
$this->ComputeStopWatchesDeadline(false);
$this->OnUpdate();
$this->FireEventBeforeDatabaseUpdate();
$this->FireEventBeforeObjectUpdate();
// Freeze the changes at this point
$this->InitPreviousValuesForUpdatedAttributes();
@@ -6061,7 +6061,7 @@ abstract class DBObject implements iDisplay
* @return void
* @since 3.1.0
*/
protected function FireEventBeforeDatabaseCreate()
protected function FireEventBeforeObjectCreate()
{
}
@@ -6081,7 +6081,7 @@ abstract class DBObject implements iDisplay
* @return void
* @since 3.1.0
*/
protected function FireEventBeforeDatabaseUpdate()
protected function FireEventBeforeObjectUpdate()
{
}