WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Routes

AbstractRoute::prepare_response_for_collection() protected WC 1.0

Prepares a response for insertion into a collection.

{} It's a 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.

Code of AbstractRoute::prepare_response_for_collection() WC 5.8.0

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;
}