diff --git a/src/RestApi/Version4/AbstractController.php b/src/RestApi/Version4/Controllers/AbstractController.php similarity index 99% rename from src/RestApi/Version4/AbstractController.php rename to src/RestApi/Version4/Controllers/AbstractController.php index d49a1df39d8..883f6d96b3e 100644 --- a/src/RestApi/Version4/AbstractController.php +++ b/src/RestApi/Version4/Controllers/AbstractController.php @@ -13,7 +13,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4; +namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/AbstractObjectsController.php b/src/RestApi/Version4/Controllers/AbstractObjectsController.php similarity index 99% rename from src/RestApi/Version4/AbstractObjectsController.php rename to src/RestApi/Version4/Controllers/AbstractObjectsController.php index 005ee51f3aa..6373502db3b 100644 --- a/src/RestApi/Version4/AbstractObjectsController.php +++ b/src/RestApi/Version4/Controllers/AbstractObjectsController.php @@ -13,8 +13,6 @@ use AbstractPostsController; /** * CRUD Object Controller. - * - * @extends WC_REST_Posts_Controller */ abstract class AbstractObjectsController extends AbstractPostsController { diff --git a/src/RestApi/Version4/AbstractPostsController.php b/src/RestApi/Version4/Controllers/AbstractPostsController.php similarity index 100% rename from src/RestApi/Version4/AbstractPostsController.php rename to src/RestApi/Version4/Controllers/AbstractPostsController.php diff --git a/src/RestApi/Version4/AbstractShippingZonesController.php b/src/RestApi/Version4/Controllers/AbstractShippingZonesController.php similarity index 97% rename from src/RestApi/Version4/AbstractShippingZonesController.php rename to src/RestApi/Version4/Controllers/AbstractShippingZonesController.php index d8b25e23a23..f99a3cc547c 100644 --- a/src/RestApi/Version4/AbstractShippingZonesController.php +++ b/src/RestApi/Version4/Controllers/AbstractShippingZonesController.php @@ -20,7 +20,7 @@ use AbstractController; * @package WooCommerce/RestApi * @extends AbstractController */ -abstract class WC_REST_Shipping_Zones_Controller_Base extends AbstractController { +abstract class AbstractShippingZonesController extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/AbstractTermsContoller.php b/src/RestApi/Version4/Controllers/AbstractTermsContoller.php similarity index 100% rename from src/RestApi/Version4/AbstractTermsContoller.php rename to src/RestApi/Version4/Controllers/AbstractTermsContoller.php diff --git a/src/RestApi/Version4/Controllers/Coupons.php b/src/RestApi/Version4/Controllers/Coupons.php index 85cc298229f..a1ef7cfb71c 100644 --- a/src/RestApi/Version4/Controllers/Coupons.php +++ b/src/RestApi/Version4/Controllers/Coupons.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Posts_Controller; - /** * REST API Coupons controller class. */ -class Coupons extends WC_REST_Posts_Controller { +class Coupons extends AbstractPostsController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/CustomerDownloads.php b/src/RestApi/Version4/Controllers/CustomerDownloads.php index 2e6de771f6b..e29e1e7867f 100644 --- a/src/RestApi/Version4/Controllers/CustomerDownloads.php +++ b/src/RestApi/Version4/Controllers/CustomerDownloads.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Customer Downloads controller class. */ -class CustomerDownloads extends WC_REST_Controller { +class CustomerDownloads extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/Customers.php b/src/RestApi/Version4/Controllers/Customers.php index e5f866b82d8..34e0d1d373f 100644 --- a/src/RestApi/Version4/Controllers/Customers.php +++ b/src/RestApi/Version4/Controllers/Customers.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Customers controller class. */ -class Customers extends WC_REST_Controller { +class Customers extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/Data.php b/src/RestApi/Version4/Controllers/Data.php index b78d89a4d71..767183e26d5 100644 --- a/src/RestApi/Version4/Controllers/Data.php +++ b/src/RestApi/Version4/Controllers/Data.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Coupons controller class. */ -class Data extends WC_REST_Controller { +class Data extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/OrderNotes.php b/src/RestApi/Version4/Controllers/OrderNotes.php index 7861423963b..496da144226 100644 --- a/src/RestApi/Version4/Controllers/OrderNotes.php +++ b/src/RestApi/Version4/Controllers/OrderNotes.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Order Notes controller class. */ -class OrderNotes extends WC_REST_Controller { +class OrderNotes extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/OrderRefunds.php b/src/RestApi/Version4/Controllers/OrderRefunds.php index 6e55da12263..8f060695af5 100644 --- a/src/RestApi/Version4/Controllers/OrderRefunds.php +++ b/src/RestApi/Version4/Controllers/OrderRefunds.php @@ -11,8 +11,6 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Orders as Orders; - /** * REST API Order Refunds controller class. */ diff --git a/src/RestApi/Version4/Controllers/Orders.php b/src/RestApi/Version4/Controllers/Orders.php index cb76817f527..3d96ac4d35b 100644 --- a/src/RestApi/Version4/Controllers/Orders.php +++ b/src/RestApi/Version4/Controllers/Orders.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_CRUD_Controller; - /** * REST API Orders controller class. */ -class Orders extends WC_REST_CRUD_Controller { +class Orders extends AbstractObjectsController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/ProductAttributeTerms.php b/src/RestApi/Version4/Controllers/ProductAttributeTerms.php index 141e17c74e6..06caad9a04f 100644 --- a/src/RestApi/Version4/Controllers/ProductAttributeTerms.php +++ b/src/RestApi/Version4/Controllers/ProductAttributeTerms.php @@ -11,8 +11,6 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use AbstractTermsContoller; - /** * REST API Product Attribute Terms controller class. */ diff --git a/src/RestApi/Version4/Controllers/ProductAttributes.php b/src/RestApi/Version4/Controllers/ProductAttributes.php index bb701caa81a..7a5031dad33 100644 --- a/src/RestApi/Version4/Controllers/ProductAttributes.php +++ b/src/RestApi/Version4/Controllers/ProductAttributes.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Product Attributes controller class. */ -class ProductAttributes extends WC_REST_Controller { +class ProductAttributes extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/ProductCategories.php b/src/RestApi/Version4/Controllers/ProductCategories.php index 25e8527198f..d708ebb39f2 100644 --- a/src/RestApi/Version4/Controllers/ProductCategories.php +++ b/src/RestApi/Version4/Controllers/ProductCategories.php @@ -11,8 +11,6 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use AbstractTermsContoller; - /** * REST API Product Categories controller class. */ diff --git a/src/RestApi/Version4/Controllers/ProductReviews.php b/src/RestApi/Version4/Controllers/ProductReviews.php index 026ff50c933..432b4c77316 100644 --- a/src/RestApi/Version4/Controllers/ProductReviews.php +++ b/src/RestApi/Version4/Controllers/ProductReviews.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Product Reviews controller class. */ -class ProductReviews extends WC_REST_Controller { +class ProductReviews extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/ProductShippingClasses.php b/src/RestApi/Version4/Controllers/ProductShippingClasses.php index dc8aee04bbd..2d23f4538d2 100644 --- a/src/RestApi/Version4/Controllers/ProductShippingClasses.php +++ b/src/RestApi/Version4/Controllers/ProductShippingClasses.php @@ -11,8 +11,6 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use AbstractTermsContoller; - /** * REST API Product Shipping Classes controller class. */ diff --git a/src/RestApi/Version4/Controllers/ProductTags.php b/src/RestApi/Version4/Controllers/ProductTags.php index bf360176d60..1c88233f4aa 100644 --- a/src/RestApi/Version4/Controllers/ProductTags.php +++ b/src/RestApi/Version4/Controllers/ProductTags.php @@ -11,8 +11,6 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use AbstractTermsContoller; - /** * REST API Product Tags controller class. */ diff --git a/src/RestApi/Version4/Controllers/Products.php b/src/RestApi/Version4/Controllers/Products.php index ca139ab7a39..df2c7e7fd56 100644 --- a/src/RestApi/Version4/Controllers/Products.php +++ b/src/RestApi/Version4/Controllers/Products.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_CRUD_Controller; - /** * REST API Products controller class. */ -class Products extends WC_REST_CRUD_Controller { +class Products extends AbstractObjectsController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/Reports.php b/src/RestApi/Version4/Controllers/Reports.php index d8f16389084..5ca2d516e75 100644 --- a/src/RestApi/Version4/Controllers/Reports.php +++ b/src/RestApi/Version4/Controllers/Reports.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API reports controller class. */ -class Reports extends WC_REST_Controller { +class Reports extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/class-wc-rest-shipping-zone-locations-v2-controller.php b/src/RestApi/Version4/Controllers/ShippingZoneLocations.php similarity index 94% rename from src/RestApi/Version4/class-wc-rest-shipping-zone-locations-v2-controller.php rename to src/RestApi/Version4/Controllers/ShippingZoneLocations.php index 4fd40bc9060..19a9d5c29b3 100644 --- a/src/RestApi/Version4/class-wc-rest-shipping-zone-locations-v2-controller.php +++ b/src/RestApi/Version4/Controllers/ShippingZoneLocations.php @@ -5,25 +5,25 @@ * Handles requests to the /shipping/zones//locations endpoint. * * @package WooCommerce/RestApi - * @since 3.0.0 */ +namespace WooCommerce\RestApi\Version4\Controllers; + defined( 'ABSPATH' ) || exit; /** * REST API Shipping Zone Locations class. - * - * @package WooCommerce/RestApi - * @extends WC_REST_Shipping_Zones_Controller_Base */ -class WC_REST_Shipping_Zone_Locations_V2_Controller extends WC_REST_Shipping_Zones_Controller_Base { +class ShippingZoneLocations extends AbstractShippingZonesController { /** * Register the routes for Shipping Zone Locations. */ public function register_routes() { register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/locations', array( + $this->namespace, + '/' . $this->rest_base . '/(?P[\d]+)/locations', + array( 'args' => array( 'id' => array( 'description' => __( 'Unique ID for the resource.', 'woocommerce' ), diff --git a/src/RestApi/Version4/class-wc-rest-shipping-zone-methods-v2-controller.php b/src/RestApi/Version4/Controllers/ShippingZoneMethods.php similarity index 97% rename from src/RestApi/Version4/class-wc-rest-shipping-zone-methods-v2-controller.php rename to src/RestApi/Version4/Controllers/ShippingZoneMethods.php index 3cd52028ea6..979026f0948 100644 --- a/src/RestApi/Version4/class-wc-rest-shipping-zone-methods-v2-controller.php +++ b/src/RestApi/Version4/Controllers/ShippingZoneMethods.php @@ -5,25 +5,25 @@ * Handles requests to the /shipping/zones//methods endpoint. * * @package WooCommerce/RestApi - * @since 3.0.0 */ +namespace WooCommerce\RestApi\Version4\Controllers; + defined( 'ABSPATH' ) || exit; /** * REST API Shipping Zone Methods class. - * - * @package WooCommerce/RestApi - * @extends WC_REST_Shipping_Zones_Controller_Base */ -class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones_Controller_Base { +class ShippingZoneMethods extends AbstractShippingZonesController { /** * Register the routes for Shipping Zone Methods. */ public function register_routes() { register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/methods', array( + $this->namespace, + '/' . $this->rest_base . '/(?P[\d]+)/methods', + array( 'args' => array( 'zone_id' => array( 'description' => __( 'Unique ID for the zone.', 'woocommerce' ), @@ -40,7 +40,8 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => array_merge( - $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + array( 'method_id' => array( 'required' => true, 'readonly' => false, @@ -54,7 +55,9 @@ class WC_REST_Shipping_Zone_Methods_V2_Controller extends WC_REST_Shipping_Zones ); register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)/methods/(?P[\d]+)', array( + $this->namespace, + '/' . $this->rest_base . '/(?P[\d]+)/methods/(?P[\d]+)', + array( 'args' => array( 'zone_id' => array( 'description' => __( 'Unique ID for the zone.', 'woocommerce' ), diff --git a/src/RestApi/Version4/class-wc-rest-shipping-zones-v2-controller.php b/src/RestApi/Version4/Controllers/ShippingZones.php similarity index 96% rename from src/RestApi/Version4/class-wc-rest-shipping-zones-v2-controller.php rename to src/RestApi/Version4/Controllers/ShippingZones.php index 17038d2d9e5..5b689046078 100644 --- a/src/RestApi/Version4/class-wc-rest-shipping-zones-v2-controller.php +++ b/src/RestApi/Version4/Controllers/ShippingZones.php @@ -5,25 +5,25 @@ * Handles requests to the /shipping/zones endpoint. * * @package WooCommerce/RestApi - * @since 3.0.0 */ +namespace WooCommerce\RestApi\Version4\Controllers; + defined( 'ABSPATH' ) || exit; /** * REST API Shipping Zones class. - * - * @package WooCommerce/RestApi - * @extends WC_REST_Shipping_Zones_Controller_Base */ -class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Controller_Base { +class ShippingZones extends AbstractShippingZonesController { /** * Register the routes for Shipping Zones. */ public function register_routes() { register_rest_route( - $this->namespace, '/' . $this->rest_base, array( + $this->namespace, + '/' . $this->rest_base, + array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), @@ -34,7 +34,8 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro 'callback' => array( $this, 'create_item' ), 'permission_callback' => array( $this, 'create_item_permissions_check' ), 'args' => array_merge( - $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + array( 'name' => array( 'required' => true, 'type' => 'string', @@ -48,7 +49,9 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro ); register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P[\d-]+)', array( + $this->namespace, + '/' . $this->rest_base . '/(?P[\d-]+)', + array( 'args' => array( 'id' => array( 'description' => __( 'Unique ID for the resource.', 'woocommerce' ), diff --git a/src/RestApi/Version4/Controllers/SystemStatus.php b/src/RestApi/Version4/Controllers/SystemStatus.php index 2919b5557c7..de3298cd846 100644 --- a/src/RestApi/Version4/Controllers/SystemStatus.php +++ b/src/RestApi/Version4/Controllers/SystemStatus.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API System Status controller class. */ -class SystemStatus extends WC_REST_Controller { +class SystemStatus extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/SystemStatusTools.php b/src/RestApi/Version4/Controllers/SystemStatusTools.php index f38b4762c35..d60944a7ef1 100644 --- a/src/RestApi/Version4/Controllers/SystemStatusTools.php +++ b/src/RestApi/Version4/Controllers/SystemStatusTools.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API System Status Tools controller class. */ -class SystemStatusTools extends WC_REST_Controller { +class SystemStatusTools extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/TaxClasses.php b/src/RestApi/Version4/Controllers/TaxClasses.php index b5bf627c647..fd31c64b14c 100644 --- a/src/RestApi/Version4/Controllers/TaxClasses.php +++ b/src/RestApi/Version4/Controllers/TaxClasses.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Tax Class controller class. */ -class TaxClasses extends WC_REST_Controller { +class TaxClasses extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/Taxes.php b/src/RestApi/Version4/Controllers/Taxes.php index 00bed597d31..a0d0387bd1a 100644 --- a/src/RestApi/Version4/Controllers/Taxes.php +++ b/src/RestApi/Version4/Controllers/Taxes.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Taxes controller class. */ -class Taxes extends WC_REST_Controller { +class Taxes extends AbstractController { /** * Route base. diff --git a/src/RestApi/Version4/Controllers/Webhooks.php b/src/RestApi/Version4/Controllers/Webhooks.php index c70adcd0a58..3a8989654ba 100644 --- a/src/RestApi/Version4/Controllers/Webhooks.php +++ b/src/RestApi/Version4/Controllers/Webhooks.php @@ -11,12 +11,10 @@ namespace WooCommerce\RestApi\Version4\Controllers; defined( 'ABSPATH' ) || exit; -use \WC_REST_Controller; - /** * REST API Webhooks controller class. */ -class Webhooks extends WC_REST_Controller { +class Webhooks extends AbstractController { /** * Route base.