Start change on Item metadata api

This commit is contained in:
Leo Germani 2018-02-15 10:46:16 -02:00
parent 76f2d5d868
commit 30c51901f9
2 changed files with 18 additions and 3 deletions

View File

@ -87,10 +87,13 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_REST_Controller {
public function prepare_item_for_response( $item, $request ) {
$field_as = [];
foreach ( $item as $field ) {
$field_as[] = $field->__toArray();
foreach ( $item as $item_metadata ) {
$field_as[] = $item_metadata->__toArray();
//$field_as['field']['field_type_object'] = $item_metadata->get_field()->get_field_type_object()->__toArray();
}
return $field_as;
}

View File

@ -82,5 +82,17 @@ abstract class Field_Type {
public function form(){
}
public function __toArray(){
$attributes = [];
$attributes['className'] = get_class($this);
$attributes['core'] = $this->core;
$attributes['component'] = $this->get_component();
$attributes['primitive_type'] = $this->get_primitive_type();
return $attributes;
}
}