Automattic\WooCommerce\StoreApi\Routes\V1
AbstractRoute::prepare_response_for_collection()
Prepares a response for insertion into a collection.
Method of the class: AbstractRoute{}
No Hooks.
Return
Array|Mixed
. Response data, ready for insertion into collection data.
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_response_for_collection( $response );
- $response(\WP_REST_Response) (required)
- Response object.
AbstractRoute::prepare_response_for_collection() AbstractRoute::prepare response for collection code WC 9.3.3
protected function prepare_response_for_collection( \WP_REST_Response $response ) { $data = (array) $response->get_data(); $server = rest_get_server(); $links = $server::get_compact_response_links( $response ); if ( ! empty( $links ) ) { $data['_links'] = $links; } return $data; }