Automattic\WooCommerce\Internal\PushNotifications\Controllers

NotificationPreferencesRestController::register_routespublicWC 10.8.0

Register the REST API endpoints handled by this controller.

Method of the class: NotificationPreferencesRestController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$NotificationPreferencesRestController = new NotificationPreferencesRestController();
$NotificationPreferencesRestController->register_routes(): void;

Changelog

Since 10.8.0 Introduced.

NotificationPreferencesRestController::register_routes() code WC 11.0.1

public function register_routes(): void {
	register_rest_route(
		$this->route_namespace,
		$this->rest_base,
		array(
			array(
				'methods'             => WP_REST_Server::READABLE,
				'callback'            => fn ( WP_REST_Request $request ) => $this->run( $request, 'get_preferences' ),
				'permission_callback' => array( $this, 'authorize_as_authenticated' ),
			),
			array(
				'methods'             => WP_REST_Server::EDITABLE,
				'callback'            => fn ( WP_REST_Request $request ) => $this->run( $request, 'update_preferences' ),
				'permission_callback' => array( $this, 'authorize_as_authenticated' ),
				'args'                => $this->get_args(),
			),
		)
	);
}