Add an example for Hooks::SET_ITEM_IMPACT_ICON

This commit is contained in:
Cédric Anne 2024-07-01 16:38:26 +02:00
parent 3e3ba0128f
commit 115c355eb2
3 changed files with 19 additions and 0 deletions

View File

@ -703,3 +703,14 @@ function plugin_example_filter_actors(array $params = []): array {
return $params;
}
function plugin_example_set_impact_icon(array $params) {
$itemtype = $params['itemtype'];
$items_id = $params['items_id'];
$item = getItemForItemtype($itemtype);
if ($item instanceof Computer && $item->getFromDB($items_id)) {
return Plugin::getWebDir('example', true, false) . '/public/computer_icon.svg';
}
return null;
}

5
public/computer_icon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -258,6 +258,9 @@ function plugin_init_example() {
$PLUGIN_HOOKS[Hooks::DASHBOARD_FILTERS]['example'] = [
ComputerModelFilter::class
];
// Icon in the impact analysis
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
}