mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-06 09:34:13 +01:00
N°7157 - Change way to pass calling trigger to action in order to ease extensibility and to be able to use its attributes in placeholders
This commit is contained in:
@@ -41,12 +41,6 @@ require_once(APPROOT.'/core/email.class.inc.php');
|
||||
*/
|
||||
abstract class Action extends cmdbAbstractObject
|
||||
{
|
||||
/**
|
||||
* @var $oCallingTrigger Trigger|null The trigger that called this action {@see DoExecute}
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?Trigger $oCallingTrigger = null;
|
||||
|
||||
/**
|
||||
* @throws \CoreException
|
||||
* @throws \Exception
|
||||
@@ -276,14 +270,6 @@ abstract class ActionNotification extends Action
|
||||
// MetaModel::Init_SetZListItems('default_search', array('name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function DoExecute($oTrigger, $aContextArgs)
|
||||
{
|
||||
$this->oCallingTrigger = $oTrigger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sLanguage
|
||||
* @param $sLanguageCode
|
||||
@@ -447,7 +433,7 @@ class ActionEmail extends ActionNotification
|
||||
*/
|
||||
protected function FindRecipients($sRecipAttCode, $aArgs)
|
||||
{
|
||||
$oTrigger = $this->oCallingTrigger;
|
||||
$oTrigger = $aArgs['trigger->object()'];
|
||||
$sOQL = $this->Get($sRecipAttCode);
|
||||
if (utils::IsNullOrEmptyString($sOQL)) return '';
|
||||
|
||||
@@ -523,7 +509,6 @@ class ActionEmail extends ActionNotification
|
||||
*/
|
||||
public function DoExecute($oTrigger, $aContextArgs)
|
||||
{
|
||||
parent::DoExecute($oTrigger, $aContextArgs);
|
||||
if (MetaModel::IsLogEnabledNotification())
|
||||
{
|
||||
$oLog = new EventNotificationEmail();
|
||||
|
||||
@@ -112,6 +112,8 @@ abstract class Trigger extends cmdbAbstractObject
|
||||
return;
|
||||
}
|
||||
|
||||
$aContextArgs['trigger->object()'] = $this;
|
||||
|
||||
// Find the related actions
|
||||
$oLinkedActions = $this->Get('action_list');
|
||||
|
||||
@@ -121,7 +123,7 @@ abstract class Trigger extends cmdbAbstractObject
|
||||
$aActionListOrdered[(int) $oLink->Get('order')][] = $oLink;
|
||||
}
|
||||
ksort($aActionListOrdered);
|
||||
|
||||
|
||||
// Execute actions
|
||||
foreach ($aActionListOrdered as $aActionSubList) {
|
||||
foreach ($aActionSubList as $oLink) /** @var \DBObject $oLink */ {
|
||||
@@ -131,6 +133,7 @@ abstract class Trigger extends cmdbAbstractObject
|
||||
$oAction = MetaModel::GetObject('Action', $iActionId);
|
||||
if ($oAction->IsActive()) {
|
||||
$oKPI = new ExecutionKPI();
|
||||
$aContextArgs['action->object()'] = $oAction;
|
||||
$oAction->DoExecute($this, $aContextArgs);
|
||||
$oKPI->ComputeStatsForExtension($oAction, 'DoExecute');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user