Skip to content

Commit

Permalink
Add an example for Hooks::SET_ITEM_IMPACT_ICON
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Nov 27, 2024
1 parent 3e3ba01 commit 115c355
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 5 additions & 0 deletions public/computer_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}


Expand Down

0 comments on commit 115c355

Please sign in to comment.