diff --git a/src/classes/api/endpoints/class-tainacan-rest-metadata-section-controller.php b/src/classes/api/endpoints/class-tainacan-rest-metadata-section-controller.php index c16283d6d..a63da5089 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-metadata-section-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-metadata-section-controller.php @@ -20,6 +20,7 @@ class REST_Metadata_Section_Controller extends REST_Controller { */ public function init_objects() { $this->metadatum_section_repository = Repositories\Metadata_Section::get_instance(); + $this->metadatum_repository = Repositories\Metadata::get_instance(); } /** @@ -250,6 +251,15 @@ class REST_Metadata_Section_Controller extends REST_Controller { // $item_arr['enabled'] = $item->get_enabled_for_collection(); } + if( !empty($item_arr['metadatum_list']) ) { + $metadatum_list = $item_arr['metadatum_list']; + $item_arr['metadatum_object_list'] = []; + foreach($metadatum_list as $metadatum_id) { + $meta = $this->metadatum_repository->fetch($metadatum_id, 'OBJECT'); + $item_arr['metadatum_object_list'][] = $meta->_toArray(); + } + } + /** * Use this filter to add additional post_meta to the api response * Use the $request object to get the context of the request and other variables @@ -283,10 +293,6 @@ class REST_Metadata_Section_Controller extends REST_Controller { $args['include_disabled'] = true; } - if ($request['include_control_metadata_types'] === 'true') { - $args['include_control_metadata_types'] = true; - } - $collection = new Entities\Collection( $collection_id ); $result = $this->metadatum_section_repository->fetch_by_collection( $collection, $args ); diff --git a/tests/test-api-metadata-section.php b/tests/test-api-metadata-section.php index 105df5620..00adca4ba 100644 --- a/tests/test-api-metadata-section.php +++ b/tests/test-api-metadata-section.php @@ -360,7 +360,6 @@ class TAINACAN_REST_Metadata_Section_Controller extends TAINACAN_UnitApiTestCase ); $response = $this->server->dispatch($request); $response_data = $response->get_data(); - // echo json_encode( $response_data ); $this->assertEquals(2, count($response_data)); }