feat: add name of metadata type #483

This commit is contained in:
vnmedeiros 2021-03-04 23:36:37 -03:00
parent 883ca1cb37
commit bd0cb8354d
1 changed files with 8 additions and 1 deletions

View File

@ -242,9 +242,16 @@ class REST_Reports_Controller extends REST_Controller {
foreach($result_metadatum as $metadatum) { foreach($result_metadatum as $metadatum) {
$meta_type = explode('\\', $metadatum->get_metadata_type()) ; $meta_type = explode('\\', $metadatum->get_metadata_type()) ;
$meta_type = strtolower($meta_type[sizeof($meta_type)-1]); $meta_type = strtolower($meta_type[sizeof($meta_type)-1]);
$meta_type_name = $metadatum->get_metadata_type_object()->get_name();
if( in_array($meta_type, ['core_description','core_title']) ) {
$meta_type = 'text';
$meta_type_name = (new \Tainacan\Metadata_Types\Text())->get_name();
}
$response['totals']['metadata'][$metadatum->get_status()]++; $response['totals']['metadata'][$metadatum->get_status()]++;
$response['totals']['metadata_per_type'][$meta_type]++; $response['totals']['metadata_per_type'][$meta_type]['name'] = $meta_type_name;
$response['totals']['metadata_per_type'][$meta_type]['count']++;
$meta_ids[] = $metadatum->get_id(); $meta_ids[] = $metadatum->get_id();
} }
$response['distribution'] = $this->query_item_metadata_distribution($meta_ids, $collection->get_db_identifier()); $response['distribution'] = $this->query_item_metadata_distribution($meta_ids, $collection->get_db_identifier());