fix: get number instead array on metadata collection level
This commit is contained in:
parent
35d0ceba8a
commit
2ec4fbe3d5
|
@ -259,7 +259,10 @@ class Metadatum extends Entity {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_metadata_section_id() {
|
function get_metadata_section_id() {
|
||||||
return $this->get_mapped_property('metadata_section_id');
|
$mapped_metadata_section_id = $this->get_mapped_property('metadata_section_id');
|
||||||
|
if($this->is_repository_level())
|
||||||
|
return $mapped_metadata_section_id;
|
||||||
|
return is_array($mapped_metadata_section_id) ? $mapped_metadata_section_id[0] : $mapped_metadata_section_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -354,7 +354,7 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
||||||
$section1 = $this->tainacan_entity_factory->create_entity(
|
$section1 = $this->tainacan_entity_factory->create_entity(
|
||||||
'Metadata_Section',
|
'Metadata_Section',
|
||||||
array(
|
array(
|
||||||
'name' => 'Section',
|
'name' => 'Section-1',
|
||||||
'description' => 'Section Description',
|
'description' => 'Section Description',
|
||||||
'collection' => $collection,
|
'collection' => $collection,
|
||||||
// 'metadata_list' => [$metadatum_1->get_id(), $metadatum_2->get_id()]
|
// 'metadata_list' => [$metadatum_1->get_id(), $metadatum_2->get_id()]
|
||||||
|
@ -366,7 +366,7 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
||||||
$section2 = $this->tainacan_entity_factory->create_entity(
|
$section2 = $this->tainacan_entity_factory->create_entity(
|
||||||
'Metadata_Section',
|
'Metadata_Section',
|
||||||
array(
|
array(
|
||||||
'name' => 'Section',
|
'name' => 'Section-2',
|
||||||
'description' => 'Section Description',
|
'description' => 'Section Description',
|
||||||
'collection' => $collection,
|
'collection' => $collection,
|
||||||
// 'metadata_list' => [$metadatum_3->get_id(), $metadatum_4->get_id()]
|
// 'metadata_list' => [$metadatum_3->get_id(), $metadatum_4->get_id()]
|
||||||
|
@ -428,6 +428,21 @@ class TAINACAN_REST_Metadata_Sections_Controller extends TAINACAN_UnitApiTestCas
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||||
|
$collection->set_metadata_section_order(
|
||||||
|
[
|
||||||
|
array( 'id' => $section1->get_id(), 'enabled' => true, 'metadata_order' => [
|
||||||
|
array( 'id' => $metadatum_1->get_id(), 'enabled' => true ),
|
||||||
|
array( 'id' => $metadatum_2->get_id(), 'enabled' => true )
|
||||||
|
] ),
|
||||||
|
array( 'id' => $section2->get_id(), 'enabled' => true, 'metadata_order' => [
|
||||||
|
array( 'id' => $metadatum_3->get_id(), 'enabled' => true ),
|
||||||
|
array( 'id' => $metadatum_4->get_id(), 'enabled' => true )
|
||||||
|
])
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$Tainacan_Collections->update( $collection );
|
||||||
|
|
||||||
$request = new \WP_REST_Request(
|
$request = new \WP_REST_Request(
|
||||||
'GET',
|
'GET',
|
||||||
$this->namespace . '/collection/' . $collection->get_id() . '/metadata-sections'
|
$this->namespace . '/collection/' . $collection->get_id() . '/metadata-sections'
|
||||||
|
|
Loading…
Reference in New Issue