Skip to content

Commit 1be0897

Browse files
authored
Fix(core): check GLPI version before call hook not released yet
closes #85
1 parent 5a54ffe commit 1be0897

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,11 @@ function plugin_init_example() {
260260
$PLUGIN_HOOKS[Hooks::PRE_ITEM_FORM]['example'] = [ItemForm::class, 'preItemForm'];
261261
$PLUGIN_HOOKS[Hooks::POST_ITEM_FORM]['example'] = [ItemForm::class, 'postItemForm'];
262262

263-
$PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection'];
264-
$PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection'];
263+
//TODO: remove check when GLPI 11.0.0 is released
264+
if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) {
265+
$PLUGIN_HOOKS[Hooks::PRE_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'preSection'];
266+
$PLUGIN_HOOKS[Hooks::POST_ITIL_INFO_SECTION]['example'] = [ItemForm::class, 'postSection'];
267+
}
265268

266269
// Add new actions to timeline
267270
$PLUGIN_HOOKS[Hooks::TIMELINE_ACTIONS]['example'] = [
@@ -287,8 +290,11 @@ function plugin_init_example() {
287290
ComputerModelFilter::class
288291
];
289292

290-
// Icon in the impact analysis
291-
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
293+
//TODO: remove check when GLPI 11.0.0 is released
294+
if (version_compare(GLPI_VERSION, '11.0.0', 'ge')) {
295+
// Icon in the impact analysis
296+
$PLUGIN_HOOKS[Hooks::SET_ITEM_IMPACT_ICON]['example'] = 'plugin_example_set_impact_icon';
297+
}
292298
}
293299

294300

0 commit comments

Comments
 (0)