mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Display events in the datamodel page
This commit is contained in:
@@ -12,6 +12,7 @@ use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockF
|
||||
use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContentWithSideContent;
|
||||
use Combodo\iTop\Service\EventService;
|
||||
|
||||
require_once('../approot.inc.php');
|
||||
require_once(APPROOT.'/application/application.inc.php');
|
||||
@@ -264,7 +265,58 @@ function DisplayTriggers($oPage, $sClass)
|
||||
cmdbAbstractObject::DisplaySet($oPage, $oSet, array('block_id' => 'triggers'));
|
||||
}
|
||||
|
||||
function DisplayEvents(WebPage $oPage, $sClass)
|
||||
{
|
||||
$aEvents = EventService::GetEventsByClass($sClass);
|
||||
$aColumns = [
|
||||
'event' => ['label' => 'Event'],
|
||||
'description' => ['label' => 'Description'],
|
||||
];
|
||||
$aRows = [];
|
||||
foreach ($aEvents as $sEvent => $aEventInfo) {
|
||||
$aDesc = $aEventInfo['description'];
|
||||
$aRows[] = [
|
||||
'event' => $sEvent,
|
||||
'description' => $aDesc['description'] ?? '',
|
||||
];
|
||||
}
|
||||
$oTable = DataTableUIBlockFactory::MakeForStaticData(Dict::S('UI:Schema:Events:Defined'), $aColumns, $aRows);
|
||||
$oPage->AddSubBlock($oTable);
|
||||
|
||||
$oObject = MetaModel::NewObject($sClass);
|
||||
$aSources = [$oObject->GetObjectUniqId()];
|
||||
foreach (MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL, false) as $sParentClass) {
|
||||
$aSources[] = $sParentClass;
|
||||
}
|
||||
$aListeners = [];
|
||||
foreach (array_keys($aEvents) as $sEvent) {
|
||||
$aListeners = array_merge($aListeners, EventService::GetListeners($sEvent, $aSources));
|
||||
}
|
||||
$aColumns = [
|
||||
'event' => ['label' => 'Event'],
|
||||
'listener' => ['label' => 'Listener'],
|
||||
'priority' => ['label' => 'Priority'],
|
||||
'module' => ['label' => 'Module'],
|
||||
];
|
||||
$aRows = [];
|
||||
foreach ($aListeners as $aListener) {
|
||||
if (is_object($aListener['callback'][0])) {
|
||||
$sListener = get_class($aListener['callback'][0]).'->'.$aListener['callback'][1].'(Combodo\iTop\Service\EventData $oEventData)';
|
||||
} else {
|
||||
$sListener = $aListener['callback'][0].'::'.$aListener['callback'][1].'(Combodo\iTop\Service\EventData $oEventData)';
|
||||
}
|
||||
$aRows[] = [
|
||||
'event' => $aListener['event'],
|
||||
'listener' => $sListener,
|
||||
'priority' => $aListener['priority'],
|
||||
'module' => $aListener['module'],
|
||||
];
|
||||
}
|
||||
|
||||
$oTable = DataTableUIBlockFactory::MakeForStaticData(Dict::S('UI:Schema:Events:Listeners'), $aColumns, $aRows);
|
||||
$oPage->AddSubBlock($oTable);
|
||||
|
||||
}
|
||||
/**
|
||||
* Display the list of classes from the business model
|
||||
*/
|
||||
@@ -1061,6 +1113,9 @@ EOF
|
||||
$oPage->SetCurrentTab('UI:Schema:Triggers');
|
||||
DisplayTriggers($oPage, $sClass);
|
||||
|
||||
$oPage->SetCurrentTab('UI:Schema:Events');
|
||||
DisplayEvents($oPage, $sClass);
|
||||
|
||||
$oPage->SetCurrentTab();
|
||||
$oPage->SetCurrentTabContainer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user