From c7e54c66c8bcd1bbd5edf72b8e1e48be9091bbcf Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 1 Jun 2022 09:09:16 +0200 Subject: [PATCH] Event "Compute Values" --- application/cmdbabstract.class.inc.php | 34 ++++---------------------- application/datamodel.application.xml | 17 +++++++++++++ core/dbobject.class.php | 8 ++++-- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 0602dfd4f..1bd3c3269 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -5723,10 +5723,6 @@ JS */ final protected function EventInsertRequested() { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - IssueLog::Debug("CRUD: DBInsert $sClass::0 Requested", LogChannels::DM_CRUD); - } $this->FireEvent(EVENT_SERVICE_DB_INSERT_REQUESTED); } @@ -5736,10 +5732,6 @@ JS */ final protected function EventInsertBefore() { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - IssueLog::Debug("CRUD: DBInsert $sClass::0 About to write in DB", LogChannels::DM_CRUD); - } $this->FireEvent(EVENT_SERVICE_DB_ABOUT_TO_INSERT); } @@ -5749,14 +5741,14 @@ JS */ final protected function EventInsertAfter() { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - IssueLog::Debug("CRUD: $sClass::{$this->m_iKey} Inserted in DB", LogChannels::DM_CRUD); - } - $this->FireEvent(EVENT_SERVICE_DB_INSERT_DONE); } + final protected function EventComputeValues() + { + $this->FireEvent(EVENT_SERVICE_DB_COMPUTE_VALUES); + } + /** * @param array $aEventData * @@ -5785,12 +5777,6 @@ JS */ final protected function EventUpdateRequested() { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - $sKey = $sClass.'::'.$this->GetKey(); - IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey Requested", LogChannels::DM_CRUD); - } - $this->FireEvent(EVENT_SERVICE_DB_UPDATE_REQUESTED); } @@ -5800,11 +5786,6 @@ JS */ final protected function EventUpdateBefore() { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - $sKey = $sClass.'::'.$this->GetKey(); - IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey About to be written in DB", LogChannels::DM_CRUD); - } $this->FireEvent(EVENT_SERVICE_DB_ABOUT_TO_UPDATE); } @@ -5816,11 +5797,6 @@ JS */ final protected function EventUpdateAfter(array $aEventData) { - $sClass = get_class($this); - if ($sClass == 'UserRequest') { - $sKey = $sClass.'::'.$this->GetKey(); - IssueLog::Debug("CRUD: DBUpdate $sClass::$sKey Updated", LogChannels::DM_CRUD); - } $this->FireEvent(EVENT_SERVICE_DB_UPDATE_DONE, $aEventData); } diff --git a/application/datamodel.application.xml b/application/datamodel.application.xml index 8b043a29f..572f21068 100644 --- a/application/datamodel.application.xml +++ b/application/datamodel.application.xml @@ -186,6 +186,23 @@ + + An object needs to be recomputed after changes + + cmdbAbstractObject + + DBObject::ComputeValues + + + The object inserted + DBObject + + + Debug string + string + + + An object insert in the database has been requested. All changes to the object will be persisted automatically. diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 0fe23d064..fd8eb79c9 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -1049,7 +1049,7 @@ abstract class DBObject implements iDisplay if ($aCallInfo["function"] != "ComputeValues") continue; return; //skip! } - + $this->EventComputeValues(); $this->ComputeValues(); } @@ -2305,7 +2305,7 @@ abstract class DBObject implements iDisplay * @throws \OQLException * */ - final public function CheckToWrite($bDoComputeValues = true) + public function CheckToWrite($bDoComputeValues = true) { if (MetaModel::SkipCheckToWrite()) { @@ -5829,6 +5829,10 @@ abstract class DBObject implements iDisplay { } + protected function EventComputeValues() + { + } + protected function EventCheckToWrite(array $aEventData) { }