REST API: Clarify arguments passed to rest route get & update callbacks.

Update doc block argument definitions to clarify that the REST API always passes an array to the `get_callback` and always passes an entity object to the `update_callback`.

Props TimothyBlynJacobs, salzano.
Fixes #44432.



git-svn-id: https://develop.svn.wordpress.org/trunk@45810 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
K. Adam White
2019-08-15 20:03:18 +00:00
parent 80e44e49e2
commit 94b8a122c4
2 changed files with 14 additions and 14 deletions
@@ -372,11 +372,11 @@ abstract class WP_REST_Controller {
*
* @since 4.7.0
*
* @param array $object Data object.
* @param WP_REST_Request $request Full details about the request.
* @param array $prepared Prepared response array.
* @param WP_REST_Request $request Full details about the request.
* @return array Modified data object with additional fields.
*/
protected function add_additional_fields_to_object( $object, $request ) {
protected function add_additional_fields_to_object( $prepared, $request ) {
$additional_fields = $this->get_additional_fields();
@@ -392,10 +392,10 @@ abstract class WP_REST_Controller {
continue;
}
$object[ $field_name ] = call_user_func( $field_options['get_callback'], $object, $field_name, $request, $this->get_object_type() );
$prepared[ $field_name ] = call_user_func( $field_options['get_callback'], $prepared, $field_name, $request, $this->get_object_type() );
}
return $object;
return $prepared;
}
/**
@@ -403,7 +403,7 @@ abstract class WP_REST_Controller {
*
* @since 4.7.0
*
* @param array $object Data Object.
* @param object $object Data model like WP_Term or WP_Post.
* @param WP_REST_Request $request Full details about the request.
* @return bool|WP_Error True on success, WP_Error object if a field cannot be updated.
*/