Skip to content

Commit 115c355

Browse files
committed
Add an example for Hooks::SET_ITEM_IMPACT_ICON
1 parent 3e3ba01 commit 115c355

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

hook.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,3 +703,14 @@ function plugin_example_filter_actors(array $params = []): array {
703703

704704
return $params;
705705
}
706+
707+
function plugin_example_set_impact_icon(array $params) {
708+
$itemtype = $params['itemtype'];
709+
$items_id = $params['items_id'];
710+
711+
$item = getItemForItemtype($itemtype);
712+
if ($item instanceof Computer && $item->getFromDB($items_id)) {
713+
return Plugin::getWebDir('example', true, false) . '/public/computer_icon.svg';
714+
}
715+
return null;
716+
}

public/computer_icon.svg

Lines changed: 5 additions & 0 deletions
Loading

setup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ function plugin_init_example() {
258258
$PLUGIN_HOOKS[Hooks::DASHBOARD_FILTERS]['example'] = [
259259
ComputerModelFilter::class
260260
];
261+
262+
// Icon in the impact analysis
263+
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
261264
}
262265

263266

0 commit comments

Comments
 (0)