Skip to content

Commit a7b01dc

Browse files
authored
Add missing hooks names constants (#19343)
* Add missing import_item hooks constant * Add missing menu_toadd hook constant
1 parent 0bb65f2 commit a7b01dc

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/Html.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,8 @@ public static function generateMenuSession($force = false)
14291429
$menu = self::getMenuInfos();
14301430

14311431
// Permit to plugins to add entry to others sector !
1432-
if (isset($PLUGIN_HOOKS["menu_toadd"]) && count($PLUGIN_HOOKS["menu_toadd"])) {
1433-
foreach ($PLUGIN_HOOKS["menu_toadd"] as $plugin => $items) {
1432+
if (isset($PLUGIN_HOOKS[Hooks::MENU_TOADD]) && count($PLUGIN_HOOKS[Hooks::MENU_TOADD])) {
1433+
foreach ($PLUGIN_HOOKS[Hooks::MENU_TOADD] as $plugin => $items) {
14341434
if (!Plugin::isPluginActive($plugin)) {
14351435
continue;
14361436
}

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ public static function haveImport()
20792079
/** @var array $PLUGIN_HOOKS */
20802080
global $PLUGIN_HOOKS;
20812081

2082-
return (isset($PLUGIN_HOOKS['import_item']) && count($PLUGIN_HOOKS['import_item']));
2082+
return (isset($PLUGIN_HOOKS[Hooks::IMPORT_ITEM]) && count($PLUGIN_HOOKS[Hooks::IMPORT_ITEM]));
20832083
}
20842084

20852085
/**

src/Plugin/Hooks.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737

3838
class Hooks
3939
{
40-
// Boolean hooks
40+
// Boolean hooks
4141
const CSRF_COMPLIANT = 'csrf_compliant';
4242

43-
// File hooks
43+
// File hooks
4444
const ADD_CSS = 'add_css';
4545
const ADD_JAVASCRIPT = 'add_javascript';
4646
const ADD_JAVASCRIPT_MODULE = 'add_javascript_module';
@@ -52,7 +52,7 @@ class Hooks
5252
const ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE = 'add_javascript_module_anonymous_page';
5353
const ADD_HEADER_TAG_ANONYMOUS_PAGE = 'add_header_tag_anonymous_page';
5454

55-
// Function hooks with no parameters
55+
// Function hooks with no parameters
5656
const CHANGE_ENTITY = 'change_entity';
5757
const CHANGE_PROFILE = 'change_profile';
5858
const DISPLAY_LOGIN = 'display_login';
@@ -62,8 +62,10 @@ class Hooks
6262
const POST_INIT = 'post_init';
6363
const CONFIG_PAGE = 'config_page';
6464
const USE_MASSIVE_ACTION = 'use_massive_action';
65+
const IMPORT_ITEM = 'import_item';
66+
const MENU_TOADD = 'menu_toadd';
6567

66-
// Specific function hooks with parameters
68+
// Specific function hooks with parameters
6769
const RULE_MATCHED = 'rule_matched';
6870
const VCARD_DATA = 'vcard_data';
6971
const POST_PLUGIN_DISABLE = 'post_plugin_disable';
@@ -72,7 +74,7 @@ class Hooks
7274
const POST_PLUGIN_UNINSTALL = 'post_plugin_uninstall';
7375
const POST_PLUGIN_ENABLE = 'post_plugin_enable' ;
7476

75-
// Function hooks with parameters and output
77+
// Function hooks with parameters and output
7678
const DISPLAY_LOCKED_FIELDS = 'display_locked_fields';
7779
const MIGRATE_TYPES = 'migratetypes';
7880
const POST_KANBAN_CONTENT = 'post_kanban_content';
@@ -87,7 +89,7 @@ class Hooks
8789
const UNDISCLOSED_CONFIG_VALUE = 'undiscloseConfigValue';
8890
const FILTER_ACTORS = 'filter_actors';
8991

90-
// Item hooks expecting an 'item' parameter
92+
// Item hooks expecting an 'item' parameter
9193
const ADD_RECIPIENT_TO_TARGET = 'add_recipient_to_target';
9294
const AUTOINVENTORY_INFORMATION = 'autoinventory_information';
9395
const INFOCOM = 'infocom';
@@ -110,7 +112,7 @@ class Hooks
110112
const PRE_ITEM_RESTORE = 'pre_item_restore';
111113
const SHOW_ITEM_STATS = 'show_item_stats';
112114

113-
// Item hooks expecting an array parameter (available keys: item, options)
115+
// Item hooks expecting an array parameter (available keys: item, options)
114116
const ITEM_TRANSFER = 'item_transfer';
115117
const POST_ITEM_FORM = 'post_item_form';
116118
const POST_SHOW_ITEM = 'post_show_item';
@@ -122,17 +124,17 @@ class Hooks
122124
const TIMELINE_ANSWER_ACTIONS = 'timeline_answer_actions'; // (keys: item)
123125
const SHOW_IN_TIMELINE = 'show_in_timeline'; // (keys: item)
124126

125-
// Security hooks (data to encypt)
127+
// Security hooks (data to encypt)
126128
const SECURED_FIELDS = 'secured_fields';
127129
const SECURED_CONFIGS = 'secured_configs';
128130

129-
// Inventory hooks
131+
// Inventory hooks
130132
const PROLOG_RESPONSE = 'prolog_response';
131133
const NETWORK_DISCOVERY = 'network_discovery';
132134
const NETWORK_INVENTORY = 'network_inventory';
133135
const INVENTORY_GET_PARAMS = 'inventory_get_params';
134136

135-
// Agent contact request related hooks
137+
// Agent contact request related hooks
136138
const HANDLE_INVENTORY_TASK = 'handle_inventory_task';
137139
const HANDLE_NETDISCOVERY_TASK = 'handle_netdiscovery_task';
138140
const HANDLE_NETINVENTORY_TASK = 'handle_netinventory_task';

src/RuleImportEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function displayAdditionalRuleCondition($condition, $criteria, $name, $va
146146

147147
if ($criteria['field'] == '_source') {
148148
$tab = ['GLPI' => __('GLPI'), 'NATIVE_INVENTORY' => AutoUpdateSystem::getLabelFor(AutoUpdateSystem::NATIVE_INVENTORY)];
149-
foreach ($PLUGIN_HOOKS['import_item'] ?? [] as $plug => $types) {
149+
foreach ($PLUGIN_HOOKS[Hooks::IMPORT_ITEM] ?? [] as $plug => $types) {
150150
if (!Plugin::isPluginActive($plug)) {
151151
continue;
152152
}

0 commit comments

Comments
 (0)