create method toJSON for item-metadata entity

This commit is contained in:
Eduardo humberto 2017-12-13 10:31:45 -02:00
parent c6666accf0
commit fbc84371c5
6 changed files with 11 additions and 4 deletions

View File

@ -137,7 +137,7 @@ class TAINACAN_REST_Metadata_Controller extends WP_REST_Controller {
if($item_metadata->validate()) {
$metadata_updated = $this->item_metadata_repository->insert( $item_metadata );
return new WP_REST_Response( $metadata_updated->get_metadata()->__toJSON(), 201 );
return new WP_REST_Response( $metadata_updated->__toJSON(), 201 );
} else {
return new WP_REST_Response( $item_metadata->get_errors(), 200);
}

View File

@ -251,7 +251,7 @@ class Entity {
$attributes[$prop] = $this->get_mapped_property($prop);
}
return json_encode($attributes, JSON_NUMERIC_CHECK, JSON_UNESCAPED_UNICODE);
return json_encode($attributes, JSON_NUMERIC_CHECK);
}
}

View File

@ -25,6 +25,13 @@ class Item_Metadata_Entity extends Entity {
public function __toString(){
return 'Hello, I\'m the Item Metadata Entity';
}
public function __toJSON(){
$json['value'] = $this->get_value();
$json['item'] = $this->get_item();
$json['metadata'] = $this->get_metadata();
return json_encode($json);
}
/**
* Define the item

View File

@ -1,8 +1,8 @@
import Vue from 'vue';
import Vuex from 'vuex';
import item from './modules/item/item';
import collection from './modules/collection/collection';
import item from './modules/item/';
import collection from './modules/collection/';
Vue.use(Vuex);