Now metadata multiple and status of entities is working through API
This commit is contained in:
parent
74d0009609
commit
60e362e624
|
@ -11,8 +11,8 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
|
|||
protected function get_only_needed_attributes($entity, $map){
|
||||
|
||||
$entity_prepared = [
|
||||
'id' => $entity->get_id(),
|
||||
'description' => $entity->get_description(),
|
||||
'id' => $entity->get_id(),
|
||||
'description' => $entity->get_description(),
|
||||
];
|
||||
|
||||
if(array_key_exists('modification_date', $map)){
|
||||
|
@ -41,6 +41,10 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
|
|||
$entity_prepared['columns'] = $entity->get_columns();
|
||||
}
|
||||
|
||||
if(array_key_exists('status', $map)){
|
||||
$entity_prepared['status'] = $entity->get_status();
|
||||
}
|
||||
|
||||
return $entity_prepared;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,11 @@ class Item_Metadata extends Repository {
|
|||
$values = $item_metadata->get_value();
|
||||
|
||||
foreach ($values as $value){
|
||||
update_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $value ));
|
||||
if(array_key_exists('prev', $value)) {
|
||||
update_post_meta( $item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $value['new'] ), wp_slash($value['prev']) );
|
||||
} else {
|
||||
add_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $value ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,12 +104,14 @@ class Item_Metadata extends Repository {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Item Field objects related to an Item
|
||||
*
|
||||
* @param Entities\Item $object
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* Fetch Item Field objects related to an Item
|
||||
*
|
||||
* @param Entities\Item $object
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function fetch($object, $output = null ){
|
||||
if($object instanceof Entities\Item){
|
||||
global $Tainacan_Items, $Tainacan_Fields;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* @group queries
|
||||
* **/
|
||||
class TAINACAN_REST_Queries extends TAINACAN_UnitApiTestCase {
|
||||
|
||||
public function test_collections_queries(){
|
||||
$this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
[],
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue