Register wccom-site rest in main class.

With API moved to its own package (see #23957), controllers for wccom-
site namespace are now registered in wccom-site main class.
This commit is contained in:
Akeda Bagus 2019-07-11 18:19:08 +07:00
parent 5756766a03
commit 40201eb9c3
No known key found for this signature in database
GPG Key ID: B21A9FC4B7761412
2 changed files with 22 additions and 4 deletions

View File

@ -23,6 +23,7 @@ class WC_WCCOM_Site {
self::includes();
add_action( 'woocommerce_wccom_install_products', array( 'WC_WCCOM_Site_Installer', 'install' ) );
add_action( 'woocommerce_rest_api_get_rest_namespaces', array( __CLASS__, 'register_rest_namespace' ) );
}
/**
@ -32,6 +33,23 @@ class WC_WCCOM_Site {
require_once( WC_ABSPATH . 'includes/admin/helper/class-wc-helper.php' );
require_once( __DIR__ . '/class-wc-wccom-site-installer.php' );
}
/**
* Register wccom-site REST namespace.
*
* @param array $namespaces List of registered namespaces.
*
* @return array Registered namespaces.
*/
public static function register_rest_namespace( $namespaces ) {
require_once( __DIR__ . '/rest-api/v1/class-wc-rest-wccom-site-installer-v1-controller.php' );
$namespaces['wccom-site/v1'] = array(
'installer' => 'WC_REST_WCCOM_Site_Installer_V1_Controller',
);
return $namespaces;
}
}
WC_WCCOM_Site::load();

View File

@ -4,19 +4,19 @@
*
* Handles requests to /installer.
*
* @package WooCommerce/API
* @package WooCommerce/WCCOM_Site/REST_API
* @since 3.7.0
*/
defined( 'ABSPATH' ) || exit;
/**
* REST API WCCOM Site Installer Controller Class.
* REST API WCCOM Site Installer v1 Controller Class.
*
* @package WooCommerce/API
* @package WooCommerce/WCCOM_Site/REST_API
* @extends WC_REST_Controller
*/
class WC_REST_WCCOM_Site_Installer_Controller extends WC_REST_Controller {
class WC_REST_WCCOM_Site_Installer_V1_Controller extends WC_REST_Controller {
/**
* Endpoint namespace.