mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 17:18:51 +02:00
OnInsert and OnUpdate replacement
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1231,6 +1231,24 @@
|
||||
</state>
|
||||
</states>
|
||||
</lifecycle>
|
||||
<hooks>
|
||||
<hook id="BeforeInsert">
|
||||
<listeners>
|
||||
<listener id="OnBeforeInsertEvent">
|
||||
<callback>OnBeforeInsertEvent</callback>
|
||||
<priority>0</priority>
|
||||
</listener>
|
||||
</listeners>
|
||||
</hook>
|
||||
<hook id="BeforeUpdate">
|
||||
<listeners>
|
||||
<listener id="OnBeforeUpdateEvent">
|
||||
<callback>OnBeforeUpdateEvent</callback>
|
||||
<priority>0</priority>
|
||||
</listener>
|
||||
</listeners>
|
||||
</hook>
|
||||
</hooks>
|
||||
<methods>
|
||||
<method id="GetTicketRefFormat">
|
||||
<static>true</static>
|
||||
@@ -1581,28 +1599,26 @@
|
||||
$this->UpdateImpactedItems();
|
||||
}]]></code>
|
||||
</method>
|
||||
<method id="OnInsert">
|
||||
<method id="OnBeforeInsertEvent">
|
||||
<static>false</static>
|
||||
<access>protected</access>
|
||||
<type>Overload-DBObject</type>
|
||||
<access>public</access>
|
||||
<type>Internal</type>
|
||||
<code><![CDATA[
|
||||
protected function OnInsert()
|
||||
public function OnBeforeInsertEvent(Combodo\iTop\Service\EventData $oEventData)
|
||||
{
|
||||
parent::OnInsert();
|
||||
$this->ComputeImpactedItems();
|
||||
|
||||
$this->SetIfNull('last_update', time());
|
||||
$this->SetIfNull('start_date', time());
|
||||
}]]></code>
|
||||
</method>
|
||||
<method id="OnUpdate">
|
||||
<method id="OnBeforeUpdateEvent">
|
||||
<static>false</static>
|
||||
<access>protected</access>
|
||||
<type>Overload-DBObject</type>
|
||||
<access>public</access>
|
||||
<type>Internal</type>
|
||||
<code><![CDATA[
|
||||
protected function OnUpdate()
|
||||
public function OnBeforeUpdateEvent(Combodo\iTop\Service\EventData $oEventData)
|
||||
{
|
||||
parent::OnUpdate();
|
||||
$aChanges = $this->ListChanges();
|
||||
if (array_key_exists('functionalcis_list', $aChanges))
|
||||
{
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user