N°3508 - Add warning message on save if action has no trigger attached

This commit is contained in:
Molkobain
2021-12-04 19:43:51 +01:00
parent 9f0e2c0a3a
commit a5bf059e23
17 changed files with 49 additions and 0 deletions

View File

@@ -118,6 +118,39 @@ abstract class Action extends cmdbAbstractObject
return false;
}
}
/**
* @inheritDoc
* @since 3.0.0
*/
public function AfterInsert()
{
parent::AfterInsert();
$this->DoCheckIfHasTrigger();
}
/**
* @inheritDoc
* @since 3.0.0
*/
public function AfterUpdate()
{
parent::AfterUpdate();
$this->DoCheckIfHasTrigger();
}
/**
* Check if the Action has at least 1 trigger linked. Otherwise, it adds a warning.
* @return void
* @since 3.0.0
*/
protected function DoCheckIfHasTrigger()
{
$oTriggersSet = $this->Get('trigger_list');
if ($oTriggersSet->Count() === 0) {
$this->m_aCheckWarnings[] = Dict::S('Action:WarningNoTriggerLinked');
}
}
}
/**