feat: add `metadatum_object_list` on metadata section list #184
This commit is contained in:
parent
d30982f4b2
commit
223059b179
|
@ -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 );
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue