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.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->get_token_from_query( $request ): string;
$request(WP_REST_Request) (обязательный)
The request object.

Код PushNotificationRestController::get_token_from_query() WC 11.3.0

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 ) : '';
}