WC_REST_WCCOM_Site_Installer_Controller::success_responseprotectedWC 1.0

Generate a standardized response for a successful request.

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

Хуков нет.

Возвращает

WP_REST_Response|WP_Error.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->success_response( $product_id, ?WC_WCCOM_Site_Installation_State $state );
$product_id(int) (обязательный)
Product ID.
?WC_WCCOM_Site_Installation_State $state
.
По умолчанию: null

Код WC_REST_WCCOM_Site_Installer_Controller::success_response() WC 10.7.0

protected function success_response( $product_id, ?WC_WCCOM_Site_Installation_State $state = null ) {
	$state    = $state ?? WC_WCCOM_Site_Installation_State_Storage::get_state( $product_id );
	$response = rest_ensure_response(
		array(
			'success' => true,
			'state'   => $state ? $this->map_state_to_response( $state ) : null,
		)
	);
	$response->set_status( 200 );
	return $response;
}