@@ -70,6 +70,13 @@ public function register_routes(): void
70
70
'args ' => $ this ->get_collection_params (),
71
71
],
72
72
]);
73
+ register_rest_route ($ this ->namespace , '/ ' . $ this ->rest_base . '/index ' , [
74
+ [
75
+ 'methods ' => WP_REST_Server::READABLE ,
76
+ 'callback ' => [$ this , 'getIndex ' ],
77
+ 'permission_callback ' => [$ this , 'get_items_permissions_check ' ],
78
+ ],
79
+ ]);
73
80
register_rest_route ($ this ->namespace , '/ ' . $ this ->rest_base . '/(?P<id>[\d]+) ' , [
74
81
[
75
82
'methods ' => WP_REST_Server::READABLE ,
@@ -176,6 +183,38 @@ public function get_items($request): WP_Error|WP_REST_Response
176
183
return $ response ;
177
184
}
178
185
186
+ public function getIndex (WP_REST_Request $ request ): WP_Error |WP_REST_Response
187
+ {
188
+ $ criteria = CollectionCriteria::new ()
189
+ ->withoutPagination ();
190
+
191
+ $ views = $ this ->degreeProgramCollectionRepository ->findTranslatedCollection (
192
+ $ criteria ,
193
+ MultilingualString::DE
194
+ );
195
+
196
+ if (!$ views instanceof PaginationAwareCollection) {
197
+ return new WP_Error (
198
+ 'unexpected_error ' ,
199
+ _x (
200
+ 'Something went wrong. Please try again later. ' ,
201
+ 'rest_api: response status ' ,
202
+ 'fau-degree-program-common '
203
+ ),
204
+ ['status ' => 500 ]
205
+ );
206
+ }
207
+
208
+ $ data = [];
209
+ foreach ($ views as $ view ) {
210
+ $ data [] = $ this ->prepare_response_for_collection (
211
+ new WP_REST_Response ($ view ->asSimplifiedArray ())
212
+ );
213
+ }
214
+
215
+ return new WP_REST_Response ($ data );
216
+ }
217
+
179
218
/**
180
219
* @param WP_REST_Request $request Full data about the request.
181
220
*/
0 commit comments