Continued namespacing

This commit is contained in:
Mike Jolley 2019-05-30 15:34:34 +01:00
parent b44f6eb0d5
commit 69769bf152
57 changed files with 59 additions and 593 deletions

View File

@ -8,17 +8,16 @@
* It's required to follow "Controller Classes" guide before extending this class:
* <https://developer.wordpress.org/rest-api/extending-the-rest-api/controller-classes/>
*
* NOTE THAT ONLY CODE RELEVANT FOR MOST ENDPOINTS SHOULD BE INCLUDED INTO THIS CLASS.
* If necessary extend this class and create new abstract classes like `WC_REST_CRUD_Controller` or `WC_REST_Terms_Controller`.
*
* @class WC_REST_Controller
* @package WooCommerce/RestApi
* @see https://developer.wordpress.org/rest-api/extending-the-rest-api/controller-classes/
* @package WooCommerce/RestApi
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
namespace WooCommerce\RestApi\Version4;
defined( 'ABSPATH' ) || exit;
use \WP_REST_Controller;
/**
* Abstract Rest Controller Class
@ -27,14 +26,14 @@ if ( ! defined( 'ABSPATH' ) ) {
* @extends WP_REST_Controller
* @version 2.6.0
*/
abstract class WC_REST_Controller extends WP_REST_Controller {
abstract class AbstractController extends WP_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v1';
protected $namespace = 'wc/v4';
/**
* Route base.

View File

@ -2,28 +2,21 @@
/**
* Abstract Rest CRUD Controller Class
*
* @class WC_REST_CRUD_Controller
* @package WooCommerce/RestApi
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
namespace WooCommerce\RestApi\Version4;
defined( 'ABSPATH' ) || exit;
use AbstractPostsController;
/**
* WC_REST_CRUD_Controller class.
* CRUD Object Controller.
*
* @extends WC_REST_Posts_Controller
*/
abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v2';
abstract class AbstractObjectsController extends AbstractPostsController {
/**
* If object is hierarchical.

View File

@ -2,28 +2,21 @@
/**
* Abstract Rest Posts Controller Class
*
* @class WC_REST_Posts_Controller
* @package WooCommerce/RestApi
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
namespace WooCommerce\RestApi\Version4;
defined( 'ABSPATH' ) || exit;
use AbstractController;
/**
* WC_REST_Posts_Controller
* POSTS Controller.
*
* @package WooCommerce/RestApi
* @version 2.6.0
* @extends AbstractController
*/
abstract class WC_REST_Posts_Controller extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v1';
abstract class AbstractPostsController extends AbstractController {
/**
* Route base.

View File

@ -8,24 +8,19 @@
* @since 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use AbstractController;
/**
* REST API Shipping Zones base class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Controller
* @extends AbstractController
*/
abstract class WC_REST_Shipping_Zones_Controller_Base extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v2';
abstract class WC_REST_Shipping_Zones_Controller_Base extends AbstractController {
/**
* Route base.

View File

@ -3,17 +3,18 @@
* Abstract Rest Terms Controller
*
* @package WooCommerce/RestApi
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use AbstractController;
/**
* Terms controller class.
*/
abstract class WC_REST_Terms_Controller extends WC_REST_Controller {
abstract class AbstractTermsContoller extends AbstractController {
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_Posts_Controller;
*/
class Coupons extends WC_REST_Posts_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class CustomerDownloads extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class Customers extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class Data extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
*/
class Continents extends DataController {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
*/
class Countries extends DataController {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
*/
class Currencies extends DataController {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -17,12 +17,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Data as DataController;
* Data Download IP controller.
*/
class DownloadIPs extends DataController {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class OrderNotes extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Orders as Orders;
*/
class OrderRefunds extends Orders {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,14 +18,6 @@ use \WC_REST_CRUD_Controller;
*/
class Orders extends WC_REST_CRUD_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -11,19 +11,12 @@ namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use \WC_REST_Terms_Controller;
use AbstractTermsContoller;
/**
* REST API Product Attribute Terms controller class.
*/
class ProductAttributeTerms extends WC_REST_Terms_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
class ProductAttributeTerms extends AbstractTermsContoller {
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class ProductAttributes extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -11,19 +11,12 @@ namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use \WC_REST_Terms_Controller;
use AbstractTermsContoller;
/**
* REST API Product Categories controller class.
*/
class ProductCategories extends WC_REST_Terms_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
class ProductCategories extends AbstractTermsContoller {
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class ProductReviews extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -11,19 +11,12 @@ namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use \WC_REST_Terms_Controller;
use AbstractTermsContoller;
/**
* REST API Product Shipping Classes controller class.
*/
class ProductShippingClasses extends WC_REST_Terms_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
class ProductShippingClasses extends AbstractTermsContoller {
/**
* Route base.

View File

@ -11,19 +11,12 @@ namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
use \WC_REST_Terms_Controller;
use AbstractTermsContoller;
/**
* REST API Product Tags controller class.
*/
class ProductTags extends WC_REST_Terms_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
class ProductTags extends AbstractTermsContoller {
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_CRUD_Controller;
*/
class Products extends WC_REST_CRUD_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class Reports extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Categories extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class CouponStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*
@ -32,7 +25,6 @@ class CouponStats extends Reports {
*/
protected $rest_base = 'reports/coupons/stats';
/**
* Maps query arguments from the REST request.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Coupons extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -17,12 +17,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
* REST API CustomerStats Reports class.
*/
class CustomerStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Customers extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class DownloadStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Downloads extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -17,12 +17,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
* REST API Import Reports class.
*/
class Import extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class OrderStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Orders extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class PerformanceIndicators extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class ProductStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Products extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class RevenueStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Stock extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class StockStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class TaxStats extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Taxes extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports;
*/
class Variations extends Reports {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -5,25 +5,18 @@
* Handles requests to the /system_status endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
/**
* System status controller class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Controller
*/
class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
use \WC_REST_Controller;
/**
* Endpoint namespace.
*
* @var string
* REST API System Status controller class.
*/
protected $namespace = 'wc/v2';
class SystemStatus extends WC_REST_Controller {
/**
* Route base.

View File

@ -5,25 +5,18 @@
* Handles requests to the /system_status/tools/* endpoints.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
namespace WooCommerce\RestApi\Version4\Controllers;
defined( 'ABSPATH' ) || exit;
/**
* System status tools controller.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Controller
*/
class WC_REST_System_Status_Tools_V2_Controller extends WC_REST_Controller {
use \WC_REST_Controller;
/**
* Endpoint namespace.
*
* @var string
* REST API System Status Tools controller class.
*/
protected $namespace = 'wc/v2';
class SystemStatusTools extends WC_REST_Controller {
/**
* Route base.

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class TaxClasses extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class Taxes extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -18,13 +18,6 @@ use \WC_REST_Controller;
*/
class Webhooks extends WC_REST_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
/**
* Route base.
*

View File

@ -31,6 +31,7 @@
- `reports/downloads`
- `reports/downloads/stats`
- `reports/import`
- `data/download-ips`
## Removed endpoints

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API Setting Options Controller
*
* Handles requests to /settings/{option}
*
* @package WooCommerce Admin/API
*/
defined( 'ABSPATH' ) || exit;
/**
* Setting Options controller.
*
* @package WooCommerce Admin/API
* @extends WC_REST_Setting_Options_Controller
*/
class WC_Admin_REST_Setting_Options_Controller extends WC_REST_Setting_Options_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v4';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API Network Orders controller
*
* Handles requests to the /orders/network endpoint
*
* @package WooCommerce/RestApi
* @since 3.4.0
*/
defined( 'ABSPATH' ) || exit;
/**
* REST API Network Orders controller class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Network_Orders_V2_Controller
*/
class WC_REST_Network_Orders_Controller extends WC_REST_Network_Orders_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API WC Shipping Methods controller
*
* Handles requests to the /shipping_methods endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* Shipping methods controller class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Shipping_Methods_V2_Controller
*/
class WC_REST_Shipping_Methods_Controller extends WC_REST_Shipping_Methods_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API Shipping Zone Locations controller
*
* Handles requests to the /shipping/zones/<id>/locations endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* REST API Shipping Zone Locations class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Shipping_Zone_Locations_V2_Controller
*/
class WC_REST_Shipping_Zone_Locations_Controller extends WC_REST_Shipping_Zone_Locations_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API Shipping Zone Methods controller
*
* Handles requests to the /shipping/zones/<id>/methods endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* REST API Shipping Zone Methods class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Shipping_Zone_Methods_V2_Controller
*/
class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zone_Methods_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API Shipping Zones controller
*
* Handles requests to the /shipping/zones endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* REST API Shipping Zones class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_Shipping_Zones_V2_Controller
*/
class WC_REST_Shipping_Zones_Controller extends WC_REST_Shipping_Zones_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API WC System Status controller
*
* Handles requests to the /system_status endpoint.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* System status controller class.
*
* @package WooCommerce/RestApi
* @extends WC_REST_System_Status_V2_Controller
*/
class WC_REST_System_Status_Controller extends WC_REST_System_Status_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}

View File

@ -1,27 +0,0 @@
<?php
/**
* REST API WC System Status Tools Controller
*
* Handles requests to the /system_status/tools/* endpoints.
*
* @package WooCommerce/RestApi
* @since 3.0.0
*/
defined( 'ABSPATH' ) || exit;
/**
* System status tools controller.
*
* @package WooCommerce/RestApi
* @extends WC_REST_System_Status_Tools_V2_Controller
*/
class WC_REST_System_Status_Tools_Controller extends WC_REST_System_Status_Tools_V2_Controller {
/**
* Endpoint namespace.
*
* @var string
*/
protected $namespace = 'wc/v3';
}