From c04beea38c5b024eb7067cec834096e360904c43 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Fri, 31 Dec 2021 17:07:59 +0100 Subject: [PATCH] OnInsert and OnUpdate replacement --- core/dbobject.class.php | 9 +++-- .../datamodel.itop-request-mgmt.xml | 36 +++++++++++++------ setup/compiler.class.inc.php | 6 ++-- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 626b2ff54..e38b2825b 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -4,9 +4,9 @@ * @license http://opensource.org/licenses/AGPL-3.0 */ -use Combodo\iTop\Service\EventService; -use Combodo\iTop\Service\EventName; use Combodo\iTop\Core\MetaModel\FriendlyNameType; +use Combodo\iTop\Service\EventName; +use Combodo\iTop\Service\EventService; /** * All objects to be displayed in the application (either as a list or as details) @@ -5735,9 +5735,8 @@ abstract class DBObject implements iDisplay { $aEventData['debug_info'] = 'from: '.get_class($this).':'.$this->GetKey(); $aEventData['object'] = $this; - $aEventSources = array($this->m_sEventUniqId); - foreach (MetaModel::EnumParentClasses(get_class($this), ENUM_PARENT_CLASSES_ALL, false) as $sClass) - { + $aEventSources = [$this->m_sEventUniqId]; + foreach (MetaModel::EnumParentClasses(get_class($this), ENUM_PARENT_CLASSES_ALL, false) as $sClass) { $aEventSources[] = $sClass; } EventService::FireEvent($sEvent, $aEventSources, $aEventData); diff --git a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml index e373bc218..8fccebca8 100755 --- a/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml +++ b/datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml @@ -1231,6 +1231,24 @@ + + + + + OnBeforeInsertEvent + 0 + + + + + + + OnBeforeUpdateEvent + 0 + + + + true @@ -1581,28 +1599,26 @@ $this->UpdateImpactedItems(); }]]> - + false - protected - Overload-DBObject + public + Internal ComputeImpactedItems(); $this->SetIfNull('last_update', time()); $this->SetIfNull('start_date', time()); }]]> - + false - protected - Overload-DBObject + public + Internal ListChanges(); if (array_key_exists('functionalcis_list', $aChanges)) { diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 6867b889e..0a67cb553 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -1295,7 +1295,7 @@ EOF } if (strpos($sCallback, '::') === false) { - $sEventListener = 'array($this, \''.$sCallback.'\')'; + $sEventListener = '[$this, \''.$sCallback.'\']'; } else { @@ -3574,7 +3574,7 @@ EOF; } else { - $sEventSource = 'array("'.implode('", "', $aFilters).'")'; + $sEventSource = '["'.implode('", "', $aFilters).'"]'; } $aContexts = array(); @@ -3592,7 +3592,7 @@ EOF; } else { - $sContext = 'array("'.implode('", "', $aContexts).'")'; + $sContext = '["'.implode('", "', $aContexts).'"]'; } $aHooks[] = array(