fix: include disabled maetadata on metadata sections list #184
This commit is contained in:
parent
3c6ba76964
commit
73679153b2
|
@ -149,9 +149,12 @@ class REST_Metadata_Sections_Controller extends REST_Controller {
|
|||
$item_arr['enabled'] = $item->get_enabled_for_collection();
|
||||
}
|
||||
|
||||
$metadata_list = $item->get_id() == \Tainacan\Entities\Metadata_Section::$default_section_slug
|
||||
? $this->metadata_sections_repository->get_default_section_metadata_object_list($item->get_collection())
|
||||
: $item->get_metadata_object_list();
|
||||
$args = [];
|
||||
if ($request['include_disabled'] === 'true') {
|
||||
$args['include_disabled'] = true;
|
||||
}
|
||||
|
||||
$metadata_list = $item->get_metadata_object_list($args);
|
||||
$item_arr['metadata_object_list'] = [];
|
||||
if($metadata_list != false) {
|
||||
foreach($metadata_list as $metadata) {
|
||||
|
|
|
@ -84,14 +84,14 @@ class Metadata_Section extends Entity {
|
|||
*
|
||||
* @return [int]
|
||||
*/
|
||||
function get_metadata_object_list() {
|
||||
function get_metadata_object_list($args = []) {
|
||||
$tainacan_metadata_sections = \Tainacan\Repositories\Metadata_Sections::get_instance();
|
||||
$metadata_section_id = $this->get_id();
|
||||
|
||||
if ($metadata_section_id == static::$default_section_slug)
|
||||
return $tainacan_metadata_sections->get_default_section_metadata_object_list($this->get_collection());
|
||||
return $tainacan_metadata_sections->get_default_section_metadata_object_list($this->get_collection(), $args);
|
||||
|
||||
return $tainacan_metadata_sections->get_metadata_object_list($this->get_id());
|
||||
return $tainacan_metadata_sections->get_metadata_object_list($this->get_id(), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -366,19 +366,21 @@ class Metadata_Sections extends Repository {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function get_metadata_object_list($metadata_section_id) {
|
||||
public function get_metadata_object_list($metadata_section_id, $args = []) {
|
||||
$metadata_section = $this->fetch($metadata_section_id);
|
||||
if ($metadata_section) {
|
||||
$metadata_repository = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$metadata_list = $metadata_repository->fetch_by_metadata_section($metadata_section);
|
||||
$metadata_list = $metadata_repository->fetch_by_metadata_section($metadata_section, $args);
|
||||
return $metadata_list;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get_default_section_metadata_object_list (Entities\Collection $collection) {
|
||||
public function get_default_section_metadata_object_list (Entities\Collection $collection, $args = []) {
|
||||
$metadata_sections_ids = $this->fetch_ids();
|
||||
$args = array(
|
||||
$args = array_merge(
|
||||
$args,
|
||||
array(
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'relation' => 'OR',
|
||||
|
@ -400,6 +402,7 @@ class Metadata_Sections extends Repository {
|
|||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$metadata_repository = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$metadata_list = $metadata_repository->fetch_by_collection($collection, $args);
|
||||
|
|
Loading…
Reference in New Issue