Automattic\WooCommerce\RestApi

Server::get_rest_namespacesprotectedWC 1.0

Get API namespaces - new namespaces should be registered here.

Method of the class: Server{}

Returns

Array. List of Namespaces and Main controller classes.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_rest_namespaces();

Server::get_rest_namespaces() code WC 10.3.6

protected function get_rest_namespaces() {
	$namespaces = array(
		'wc/v1'        => wc_rest_should_load_namespace( 'wc/v1' ) ? $this->get_v1_controllers() : array(),
		'wc/v2'        => wc_rest_should_load_namespace( 'wc/v2' ) ? $this->get_v2_controllers() : array(),
		'wc/v3'        => wc_rest_should_load_namespace( 'wc/v3' ) ? $this->get_v3_controllers() : array(),
		'wc-telemetry' => wc_rest_should_load_namespace( 'wc-telemetry' ) ? $this->get_telemetry_controllers() : array(),
	);

	if ( wc_rest_should_load_namespace( 'wc/v4' ) && Features::is_enabled( 'rest-api-v4' ) ) {
		$namespaces['wc/v4'] = $this->get_v4_controllers();
	}

	/**
	 * Filter the list of REST API controllers to load.
	 *
	 * @since 4.5.0
	 * @param array $controllers List of $namespace => $controllers to load.
	 */
	return apply_filters( 'woocommerce_rest_api_get_rest_namespaces', $namespaces );
}