Add EVENT_DB_BEFORE_CREATE and EVENT_DB_BEFORE_UPDATE events in CRUD calls

This commit is contained in:
Eric Espie
2023-05-16 15:52:02 +02:00
parent 59cd489e72
commit ad25d8823f
4 changed files with 74 additions and 1 deletions

View File

@@ -3086,6 +3086,8 @@ abstract class DBObject implements iDisplay
$this->ComputeStopWatchesDeadline(true);
$this->FireEventBeforeDatabaseCreate();
$iTransactionRetry = 1;
$bIsTransactionEnabled = MetaModel::GetConfig()->Get('db_core_transactions_enabled');
if ($bIsTransactionEnabled) {
@@ -3276,6 +3278,8 @@ abstract class DBObject implements iDisplay
$this->ComputeStopWatchesDeadline(false);
$this->OnUpdate();
$this->FireEventBeforeDatabaseUpdate();
// Freeze the changes at this point
$this->InitPreviousValuesForUpdatedAttributes();
$aChanges = $this->ListChanges();
@@ -6053,6 +6057,14 @@ abstract class DBObject implements iDisplay
{
}
/**
* @return void
* @since 3.1.0
*/
protected function FireEventBeforeDatabaseCreate()
{
}
/**
* @return void
* @since 3.1.0
@@ -6069,6 +6081,16 @@ abstract class DBObject implements iDisplay
* @return void
* @since 3.1.0
*/
protected function FireEventBeforeDatabaseUpdate()
{
}
/**
* @param array $aChanges
*
* @return void
* @since 3.1.0
*/
protected function FireEventUpdateDone(array $aChanges): void
{
}
@@ -6078,6 +6100,8 @@ abstract class DBObject implements iDisplay
///
/**
* @param \DeletionPlan $oDeletionPlan
*
* @return void
* @since 3.1.0
*/