WordPress at a glance
function is not described

WP_REST_Controller::prepare_response_for_collection() public WP 4.7.0

Prepares a response for insertion into a collection.

{} It's a method of the class: WP_REST_Controller{}

No Hooks.

Return

Array/Mixed. Response data, ready for insertion into collection data.

Usage

$WP_REST_Controller = new WP_REST_Controller();
$WP_REST_Controller->prepare_response_for_collection( $response );
$response(WP_REST_Response) (required)
Response object.

Changelog

Since 4.7.0 Introduced.

Code of WP_REST_Controller::prepare_response_for_collection() WP 5.5.1

<?php
public function prepare_response_for_collection( $response ) {
	if ( ! ( $response instanceof WP_REST_Response ) ) {
		return $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;
}