Automattic\WooCommerce\StoreApi\Routes\V1

AbstractRoute::prepare_response_for_collection()protectedWC 1.0

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() code WC 8.7.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;
}