WC_REST_Customer_Downloads_V1_Controller::prepare_links()protectedWC 1.0

Prepare links for the request.

Method of the class: WC_REST_Customer_Downloads_V1_Controller{}

No Hooks.

Return

Array. Links for the given customer download.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_links( $download, $request );
$download(stdClass) (required)
Download object.
$request(WP_REST_Request) (required)
Request object.

WC_REST_Customer_Downloads_V1_Controller::prepare_links() code WC 8.7.0

protected function prepare_links( $download, $request ) {
	$base  = str_replace( '(?P<customer_id>[\d]+)', $request['customer_id'], $this->rest_base );
	$links = array(
		'collection' => array(
			'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $base ) ),
		),
		'product' => array(
			'href' => rest_url( sprintf( '/%s/products/%d', $this->namespace, $download->product_id ) ),
		),
		'order' => array(
			'href' => rest_url( sprintf( '/%s/orders/%d', $this->namespace, $download->order_id ) ),
		),
	);

	return $links;
}