Commit ea13dd1
committed
Register active custom asset definitions as orderable itemtypes (GLPI 11)
GLPI 11 introduced native custom assets defined via Setup → Asset
definitions. The plugin's hardcoded $ORDER_TYPES array in
plugin_init_order() does not include them, so custom asset classes
never appear in the Item type dropdown when creating a new Product
reference, making it impossible to order anything based on a custom
asset definition.
This commit adds an auto-registration loop that, after the existing
hardcoded itemtypes, iterates active custom asset definitions via
AssetDefinitionManager and appends each generated class name to
$ORDER_TYPES if not already present.
bootDefinitions() is called explicitly because the manager is
instantiated but not yet booted at plugin_init_order() time, so
getDefinitions() would otherwise return an empty array.
The class_exists() guard makes the block a no-op on GLPI <= 10.x,
preserving backward compatibility.
Tested on GLPI 11.0.6, PHP 8.3, with custom asset definitions on two
independent installations with different capacity sets:
- Custom asset appears in Product reference Item type dropdown.
- Type and Model dropdowns populate correctly via the existing
itemtype + 'Type' / + 'Model' class name convention.
- Order validation, item delivery, Generate item massive action,
and Reception flow all complete successfully end to end.
- The existing AssignableItem handling from #560 already works
correctly with custom asset classes once they are registered as
orderable itemtypes.1 parent 43f4e95 commit ea13dd1
2 files changed
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
128 | 141 | | |
129 | 142 | | |
130 | 143 | | |
| |||
0 commit comments