Automattic\WooCommerce\Internal\PushNotifications\Controllers

PushNotificationRestController::get_token_from_query │ private │ WC 1.0

Reads the credential from the query string.

Reads the query parameters directly rather than through WP_REST_Request::get_param(), which searches the JSON body and the POST body first and is reorderable by the rest_request_parameter_order The credential is sent in the URL, so that is the only place it should be read from.

Method of the class: PushNotificationRestController{}

No Hooks.

Returns

string. The token, or an empty string when absent or not a string.

Usage

// private - for code of main (parent) class only
$result = $this->get_token_from_query( $request ): string;
$request(WP_REST_Request) (required)
The request object.

PushNotificationRestController::get_token_from_query() code WC 11.2.1

private function get_token_from_query( WP_REST_Request $request ): string {
	$params = $request->get_query_params();
	$token  = $params[ InternalNotificationDispatcher::TOKEN_QUERY_PARAM ] ?? '';

	return is_string( $token ) ? trim( $token ) : '';
}