@@ -374,7 +374,6 @@ public static function getAPIItemtypeData(): array
374
374
ChangeTask::class => ['parent ' => Change::class],
375
375
ProblemTask::class => ['parent ' => Problem::class],
376
376
ITILFollowup::class => [], // All main types can be the parent
377
- Document_Item::class => [],
378
377
ITILSolution::class => [],
379
378
TicketValidation::class => ['parent ' => Ticket::class],
380
379
],
@@ -385,6 +384,9 @@ public static function getAPIItemtypeData(): array
385
384
Contract::class, Database::class, Datacenter::class, Document::class, Domain::class,
386
385
SoftwareLicense::class, Line::class, Supplier::class,
387
386
],
387
+ 'subtypes ' => [
388
+ Document_Item::class => ['parent ' => Document::class],
389
+ ],
388
390
],
389
391
];
390
392
@@ -438,9 +440,9 @@ public static function getAPIItemtypeData(): array
438
440
}
439
441
440
442
/**
441
- * Return a list of GLPI itemtypes availabel through HL API.
443
+ * Return a list of GLPI itemtypes available through HL API.
442
444
*
443
- * @return array
445
+ * @return array<array>
444
446
*/
445
447
public static function getItemtypesDropdownValues (): array
446
448
{
@@ -917,10 +919,19 @@ public static function getAPISchemaBySupportedItemtype(string $itemtype): ?array
917
919
$ controller_class = $ controller ;
918
920
break ;
919
921
}
922
+
920
923
if (isset ($ categories ['subtypes ' ]) && array_key_exists ($ itemtype , $ categories ['subtypes ' ])) {
921
- $ schema_name = $ categories ['subtypes ' ][$ itemtype ]['name ' ];
922
- $ schema_name = $ categories ['main ' ][$ categories ['subtypes ' ][$ itemtype ]['parent ' ]]['name ' ] . $ schema_name ;
923
924
$ controller_class = $ controller ;
925
+ $ schema_name = $ categories ['subtypes ' ][$ itemtype ]['name ' ];
926
+
927
+ if (
928
+ array_key_exists ('parent ' , $ categories ['subtypes ' ][$ itemtype ])
929
+ && array_key_exists ($ categories ['subtypes ' ][$ itemtype ]['parent ' ], $ categories ['main ' ])
930
+ && array_key_exists ('name ' , $ categories ['main ' ][$ categories ['subtypes ' ][$ itemtype ]['parent ' ]])
931
+ ) {
932
+ $ schema_name = $ categories ['main ' ][$ categories ['subtypes ' ][$ itemtype ]['parent ' ]]['name ' ] . $ schema_name ;
933
+ }
934
+
924
935
break ;
925
936
}
926
937
}
@@ -939,6 +950,9 @@ public static function getMonacoSuggestions(?string $itemtype): array
939
950
return [];
940
951
}
941
952
$ schema = self ::getAPISchemaBySupportedItemtype ($ itemtype );
953
+ if (is_null ($ schema )) {
954
+ return [];
955
+ }
942
956
$ props = Doc \Schema::flattenProperties ($ schema ['properties ' ], 'item. ' );
943
957
$ parent_schema = self ::getParentItemSchema ($ itemtype );
944
958
$ parent_props = $ parent_schema !== [] ? Doc \Schema::flattenProperties ($ parent_schema ['properties ' ], 'parent_item. ' ) : [];
@@ -953,7 +967,7 @@ public static function getMonacoSuggestions(?string $itemtype): array
953
967
$ subtype_labels = [];
954
968
if (isset ($ parent_schema ['x-subtypes ' ])) {
955
969
foreach ($ parent_schema ['x-subtypes ' ] as $ subtype ) {
956
- $ subtype_labels [$ subtype ] = $ subtype ['itemtype ' ]::getTypeName (1 );
970
+ $ subtype_labels [$ subtype[ ' itemtype ' ] ] = $ subtype ['itemtype ' ]::getTypeName (1 );
957
971
}
958
972
}
959
973
foreach ($ props as $ prop_name => $ prop_data ) {
0 commit comments