WC_REST_Webhook_Deliveries_V2_Controller::prepare_item_for_response()publicWC 1.0

Prepare a single webhook delivery output for response.

Метод класса: WC_REST_Webhook_Deliveries_V2_Controller{}

Хуки из метода

Возвращает

WP_REST_Response.

Использование

$WC_REST_Webhook_Deliveries_V2_Controller = new WC_REST_Webhook_Deliveries_V2_Controller();
$WC_REST_Webhook_Deliveries_V2_Controller->prepare_item_for_response( $log, $request );
$log(stdClass) (обязательный)
Delivery log object.
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Webhook_Deliveries_V2_Controller::prepare_item_for_response() WC 9.3.3

public function prepare_item_for_response( $log, $request ) {
	$data = (array) $log;

	$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
	$data    = $this->add_additional_fields_to_object( $data, $request );
	$data    = $this->filter_response_by_context( $data, $context );

	// Wrap the data in a response object.
	$response = rest_ensure_response( $data );

	$response->add_links( $this->prepare_links( $log ) );

	/**
	 * Filter webhook delivery object returned from the REST API.
	 *
	 * @param WP_REST_Response $response The response object.
	 * @param stdClass         $log      Delivery log object used to create response.
	 * @param WP_REST_Request  $request  Request object.
	 */
	return apply_filters( 'woocommerce_rest_prepare_webhook_delivery', $response, $log, $request );
}