From 115c355eb204cf37fa2a8a13470c08f33678f95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Mon, 1 Jul 2024 16:38:26 +0200 Subject: [PATCH] Add an example for `Hooks::SET_ITEM_IMPACT_ICON` --- hook.php | 11 +++++++++++ public/computer_icon.svg | 5 +++++ setup.php | 3 +++ 3 files changed, 19 insertions(+) create mode 100644 public/computer_icon.svg diff --git a/hook.php b/hook.php index 26bf722..73e0af8 100644 --- a/hook.php +++ b/hook.php @@ -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; +} diff --git a/public/computer_icon.svg b/public/computer_icon.svg new file mode 100644 index 0000000..66dc522 --- /dev/null +++ b/public/computer_icon.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/setup.php b/setup.php index 8c61150..f80a312 100644 --- a/setup.php +++ b/setup.php @@ -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'; }