Message improves

This commit is contained in:
weryques 2017-12-13 14:17:54 -02:00
parent e4175f83ab
commit f4d4d0312a
3 changed files with 13 additions and 21 deletions

View File

@ -170,11 +170,9 @@ class TAINACAN_REST_Collections_Controller extends WP_REST_Controller {
}
return new WP_REST_Response([
[
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $prepared_post->get_errors()
],
$prepared_post->__toJSON()
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $prepared_post->get_errors(),
'collection' => $prepared_post->__toJSON()
], 400);
}

View File

@ -198,11 +198,9 @@ class TAINACAN_REST_Items_Controller extends WP_REST_Controller {
return new WP_REST_Response([
[
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $item->get_errors()
],
$item->__toJSON()
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $item->get_errors(),
'item' => $item->__toJSON()
], 400);
}

View File

@ -125,11 +125,9 @@ class TAINACAN_REST_Metadata_Controller extends WP_REST_Controller {
}
} else {
return new WP_REST_Response([
[
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $this->metadata->get_errors()
],
$this->metadata->__toJSON(),
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $this->metadata->get_errors(),
'metadata' => $this->metadata->__toJSON(),
], 400);
}
} elseif (!empty($request['item_id']) && !empty($request->get_body())){
@ -150,12 +148,10 @@ class TAINACAN_REST_Metadata_Controller extends WP_REST_Controller {
return new WP_REST_Response( $metadata_updated->__toJSON(), 201 );
} else {
return new WP_REST_Response( [
[
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $item_metadata->get_errors()
],
$item_metadata->__toJSON(),
return new WP_REST_Response([
'error_message' => __('One or more values are invalid.', 'tainacan'),
'errors' => $item_metadata->get_errors(),
'item_metadata' => $item_metadata->__toJSON(),
], 400);
}
} else {