File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,35 @@ public function loadEntity($data)
24
24
$ this ->apiToFriendly ($ data , $ this ->getEntityMap ())
25
25
);
26
26
}
27
+
28
+ public function getNics ($ id )
29
+ {
30
+ $ page = $ this ->paginatedRequest (
31
+ $ this ->collectionPath . '/ ' . $ id . '/nics ' ,
32
+ $ currentPage = 1 ,
33
+ $ perPage = 15
34
+ );
35
+ if ($ page ->totalItems () == 0 ) {
36
+ return [];
37
+ }
38
+ $ nicClient = new NicClient ();
39
+ $ page ->serializeWith (function ($ item ) use ($ nicClient ) {
40
+ return $ nicClient ->loadEntity ($ item );
41
+ });
42
+ $ items = $ page ->getItems ();
43
+ if ($ page ->totalPages () == 1 ) {
44
+ return $ items ;
45
+ }
46
+ while ($ page ->pageNumber () < $ page ->totalPages ()) {
47
+ $ page = $ this ->getPage ($ page ->pageNumber () + 1 , $ perPage );
48
+ $ page ->serializeWith (function ($ item ) use ($ nicClient ) {
49
+ return $ nicClient ->loadEntity ($ item );
50
+ });
51
+ $ items = array_merge (
52
+ $ items ,
53
+ $ page ->getItems ()
54
+ );
55
+ }
56
+ return $ items ;
57
+ }
27
58
}
You can’t perform that action at this time.
0 commit comments