@@ -150,8 +150,15 @@ protected function getUpdateHandlers($id, $current_user): array {
150150 }
151151
152152 /**
153- * Overridable function to aggregate data in the object. Currently only used for Tasks
154- * returns the aggregated data in key value pairs
153+ * Overridable function to aggregate data in the object. Used for Tasks and Agents.
154+ *
155+ * @param object $object The object to aggregate data from.
156+ * @param array &$includedData Array passed by reference; implementations can add related resources
157+ * for inclusion in the response by appending to this array.
158+ * @return array Aggregated data as key-value pairs.
159+ *
160+ * Implementations should use $includedData to collect related resources that should be included
161+ * in the API response, such as related entities or additional data.
155162 */
156163 public static function aggregateData (object $ object , array &$ includedData =[]): array
157164 {
@@ -1183,7 +1190,7 @@ protected function processExpands(
11831190 // Add missing expands to expands in case they have been added in aggregateData()
11841191 $ expandKeys = array_keys ($ expandResult );
11851192 $ diffs = array_diff ($ expandKeys , $ expands );
1186- $ expands = array_merge ($ expandKeys , $ diffs );
1193+ $ expands = array_merge ($ expands , $ diffs );
11871194
11881195 foreach ($ expands as $ expand ) {
11891196 if (!array_key_exists ($ object ->getId (), $ expandResult [$ expand ])) {
@@ -1197,16 +1204,16 @@ protected function processExpands(
11971204 $ includedResources = self ::addToRelatedResources ($ includedResources , $ apiClass ->obj2Resource ($ expandObject ));
11981205 }
11991206 } else {
1200- if ($ expandResultObject === null ) {
1207+ if ($ expandResultObject === null ) {
12011208 // to-only relation which is nullable
12021209 continue ;
1203- }
1210+ }
12041211 $ includedResources = self ::addToRelatedResources ($ includedResources , $ apiClass ->obj2Resource ($ expandResultObject ));
12051212 }
12061213 }
12071214
12081215 return $ includedResources ;
1209- }
1216+ }
12101217
12111218 /**
12121219 * Validate if user is allowed to access hashlist
0 commit comments