diff --git a/composer.json b/composer.json index 3185cd520c3..419524bc60e 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,13 @@ "woocommerce/woocommerce-sniffs": "0.0.6" }, "autoload": { - "classmap": ["src"] + "classmap": [ + "src/Controllers/Version1", + "src/Controllers/Version2", + "src/Controllers/Version3" + ], + "psr-4": { + "WooCommerce\\RestApi\\": "src/" + } } } diff --git a/init.php b/init.php index d761c9af059..8085afe0a10 100644 --- a/init.php +++ b/init.php @@ -6,6 +6,6 @@ */ return function() { - require __DIR__ . '/src/RestApi.php'; - \WooCommerce\RestApi::instance()->init(); + require __DIR__ . '/src/Server.php'; + \WooCommerce\RestApi\Server::instance()->init(); }; diff --git a/src/RestApi/Version1/class-wc-rest-coupons-v1-controller.php b/src/Controllers/Version1/class-wc-rest-coupons-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-coupons-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-coupons-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-customer-downloads-v1-controller.php b/src/Controllers/Version1/class-wc-rest-customer-downloads-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-customer-downloads-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-customer-downloads-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-customers-v1-controller.php b/src/Controllers/Version1/class-wc-rest-customers-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-customers-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-customers-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-order-notes-v1-controller.php b/src/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-order-notes-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-order-refunds-v1-controller.php b/src/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-order-refunds-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-orders-v1-controller.php b/src/Controllers/Version1/class-wc-rest-orders-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-orders-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-orders-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-attribute-terms-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-attribute-terms-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-attribute-terms-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-attribute-terms-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-attributes-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-attributes-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-attributes-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-attributes-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-categories-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-categories-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-categories-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-categories-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-reviews-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-reviews-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-reviews-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-reviews-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-shipping-classes-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-shipping-classes-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-shipping-classes-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-shipping-classes-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-product-tags-v1-controller.php b/src/Controllers/Version1/class-wc-rest-product-tags-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-product-tags-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-product-tags-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-products-v1-controller.php b/src/Controllers/Version1/class-wc-rest-products-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-products-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-products-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-report-sales-v1-controller.php b/src/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-report-sales-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-report-top-sellers-v1-controller.php b/src/Controllers/Version1/class-wc-rest-report-top-sellers-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-report-top-sellers-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-report-top-sellers-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-reports-v1-controller.php b/src/Controllers/Version1/class-wc-rest-reports-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-reports-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-reports-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-tax-classes-v1-controller.php b/src/Controllers/Version1/class-wc-rest-tax-classes-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-tax-classes-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-tax-classes-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-taxes-v1-controller.php b/src/Controllers/Version1/class-wc-rest-taxes-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-taxes-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-taxes-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-webhook-deliveries-v1-controller.php b/src/Controllers/Version1/class-wc-rest-webhook-deliveries-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-webhook-deliveries-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-webhook-deliveries-v1-controller.php diff --git a/src/RestApi/Version1/class-wc-rest-webhooks-v1-controller.php b/src/Controllers/Version1/class-wc-rest-webhooks-v1-controller.php similarity index 100% rename from src/RestApi/Version1/class-wc-rest-webhooks-v1-controller.php rename to src/Controllers/Version1/class-wc-rest-webhooks-v1-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-coupons-v2-controller.php b/src/Controllers/Version2/class-wc-rest-coupons-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-coupons-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-coupons-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-customer-downloads-v2-controller.php b/src/Controllers/Version2/class-wc-rest-customer-downloads-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-customer-downloads-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-customer-downloads-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-customers-v2-controller.php b/src/Controllers/Version2/class-wc-rest-customers-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-customers-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-customers-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-network-orders-v2-controller.php b/src/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-network-orders-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-order-notes-v2-controller.php b/src/Controllers/Version2/class-wc-rest-order-notes-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-order-notes-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-order-notes-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-order-refunds-v2-controller.php b/src/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-order-refunds-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-orders-v2-controller.php b/src/Controllers/Version2/class-wc-rest-orders-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-orders-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-orders-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-payment-gateways-v2-controller.php b/src/Controllers/Version2/class-wc-rest-payment-gateways-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-payment-gateways-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-payment-gateways-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-attribute-terms-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-attribute-terms-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-attribute-terms-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-attribute-terms-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-attributes-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-attributes-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-attributes-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-attributes-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-categories-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-categories-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-categories-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-categories-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-reviews-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-reviews-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-reviews-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-reviews-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-shipping-classes-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-shipping-classes-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-shipping-classes-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-shipping-classes-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-tags-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-tags-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-tags-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-tags-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-product-variations-v2-controller.php b/src/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-product-variations-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-products-v2-controller.php b/src/Controllers/Version2/class-wc-rest-products-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-products-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-products-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-report-sales-v2-controller.php b/src/Controllers/Version2/class-wc-rest-report-sales-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-report-sales-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-report-sales-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-report-top-sellers-v2-controller.php b/src/Controllers/Version2/class-wc-rest-report-top-sellers-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-report-top-sellers-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-report-top-sellers-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-reports-v2-controller.php b/src/Controllers/Version2/class-wc-rest-reports-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-reports-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-reports-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-setting-options-v2-controller.php b/src/Controllers/Version2/class-wc-rest-setting-options-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-setting-options-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-setting-options-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-settings-v2-controller.php b/src/Controllers/Version2/class-wc-rest-settings-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-settings-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-settings-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-shipping-methods-v2-controller.php b/src/Controllers/Version2/class-wc-rest-shipping-methods-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-shipping-methods-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-shipping-methods-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-shipping-zone-locations-v2-controller.php b/src/Controllers/Version2/class-wc-rest-shipping-zone-locations-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-shipping-zone-locations-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-shipping-zone-locations-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php b/src/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-shipping-zones-v2-controller.php b/src/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-shipping-zones-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-system-status-tools-v2-controller.php b/src/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-system-status-tools-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-system-status-v2-controller.php b/src/Controllers/Version2/class-wc-rest-system-status-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-system-status-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-system-status-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-tax-classes-v2-controller.php b/src/Controllers/Version2/class-wc-rest-tax-classes-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-tax-classes-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-tax-classes-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-taxes-v2-controller.php b/src/Controllers/Version2/class-wc-rest-taxes-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-taxes-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-taxes-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-webhook-deliveries-v2-controller.php b/src/Controllers/Version2/class-wc-rest-webhook-deliveries-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-webhook-deliveries-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-webhook-deliveries-v2-controller.php diff --git a/src/RestApi/Version2/class-wc-rest-webhooks-v2-controller.php b/src/Controllers/Version2/class-wc-rest-webhooks-v2-controller.php similarity index 100% rename from src/RestApi/Version2/class-wc-rest-webhooks-v2-controller.php rename to src/Controllers/Version2/class-wc-rest-webhooks-v2-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-controller.php b/src/Controllers/Version3/class-wc-rest-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-controller.php rename to src/Controllers/Version3/class-wc-rest-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-coupons-controller.php b/src/Controllers/Version3/class-wc-rest-coupons-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-coupons-controller.php rename to src/Controllers/Version3/class-wc-rest-coupons-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-crud-controller.php b/src/Controllers/Version3/class-wc-rest-crud-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-crud-controller.php rename to src/Controllers/Version3/class-wc-rest-crud-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-customer-downloads-controller.php b/src/Controllers/Version3/class-wc-rest-customer-downloads-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-customer-downloads-controller.php rename to src/Controllers/Version3/class-wc-rest-customer-downloads-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-customers-controller.php b/src/Controllers/Version3/class-wc-rest-customers-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-customers-controller.php rename to src/Controllers/Version3/class-wc-rest-customers-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-data-continents-controller.php b/src/Controllers/Version3/class-wc-rest-data-continents-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-data-continents-controller.php rename to src/Controllers/Version3/class-wc-rest-data-continents-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-data-controller.php b/src/Controllers/Version3/class-wc-rest-data-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-data-controller.php rename to src/Controllers/Version3/class-wc-rest-data-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-data-countries-controller.php b/src/Controllers/Version3/class-wc-rest-data-countries-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-data-countries-controller.php rename to src/Controllers/Version3/class-wc-rest-data-countries-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-data-currencies-controller.php b/src/Controllers/Version3/class-wc-rest-data-currencies-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-data-currencies-controller.php rename to src/Controllers/Version3/class-wc-rest-data-currencies-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-network-orders-controller.php b/src/Controllers/Version3/class-wc-rest-network-orders-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-network-orders-controller.php rename to src/Controllers/Version3/class-wc-rest-network-orders-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-order-notes-controller.php b/src/Controllers/Version3/class-wc-rest-order-notes-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-order-notes-controller.php rename to src/Controllers/Version3/class-wc-rest-order-notes-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-order-refunds-controller.php b/src/Controllers/Version3/class-wc-rest-order-refunds-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-order-refunds-controller.php rename to src/Controllers/Version3/class-wc-rest-order-refunds-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-orders-controller.php b/src/Controllers/Version3/class-wc-rest-orders-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-orders-controller.php rename to src/Controllers/Version3/class-wc-rest-orders-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-payment-gateways-controller.php b/src/Controllers/Version3/class-wc-rest-payment-gateways-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-payment-gateways-controller.php rename to src/Controllers/Version3/class-wc-rest-payment-gateways-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-posts-controller.php b/src/Controllers/Version3/class-wc-rest-posts-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-posts-controller.php rename to src/Controllers/Version3/class-wc-rest-posts-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-attribute-terms-controller.php b/src/Controllers/Version3/class-wc-rest-product-attribute-terms-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-attribute-terms-controller.php rename to src/Controllers/Version3/class-wc-rest-product-attribute-terms-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-attributes-controller.php b/src/Controllers/Version3/class-wc-rest-product-attributes-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-attributes-controller.php rename to src/Controllers/Version3/class-wc-rest-product-attributes-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-categories-controller.php b/src/Controllers/Version3/class-wc-rest-product-categories-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-categories-controller.php rename to src/Controllers/Version3/class-wc-rest-product-categories-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-reviews-controller.php b/src/Controllers/Version3/class-wc-rest-product-reviews-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-reviews-controller.php rename to src/Controllers/Version3/class-wc-rest-product-reviews-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-shipping-classes-controller.php b/src/Controllers/Version3/class-wc-rest-product-shipping-classes-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-shipping-classes-controller.php rename to src/Controllers/Version3/class-wc-rest-product-shipping-classes-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-tags-controller.php b/src/Controllers/Version3/class-wc-rest-product-tags-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-tags-controller.php rename to src/Controllers/Version3/class-wc-rest-product-tags-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-product-variations-controller.php b/src/Controllers/Version3/class-wc-rest-product-variations-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-product-variations-controller.php rename to src/Controllers/Version3/class-wc-rest-product-variations-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-products-controller.php b/src/Controllers/Version3/class-wc-rest-products-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-products-controller.php rename to src/Controllers/Version3/class-wc-rest-products-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-coupons-totals-controller.php b/src/Controllers/Version3/class-wc-rest-report-coupons-totals-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-coupons-totals-controller.php rename to src/Controllers/Version3/class-wc-rest-report-coupons-totals-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-customers-totals-controller.php b/src/Controllers/Version3/class-wc-rest-report-customers-totals-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-customers-totals-controller.php rename to src/Controllers/Version3/class-wc-rest-report-customers-totals-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-orders-totals-controller.php b/src/Controllers/Version3/class-wc-rest-report-orders-totals-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-orders-totals-controller.php rename to src/Controllers/Version3/class-wc-rest-report-orders-totals-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-products-totals-controller.php b/src/Controllers/Version3/class-wc-rest-report-products-totals-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-products-totals-controller.php rename to src/Controllers/Version3/class-wc-rest-report-products-totals-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-reviews-totals-controller.php b/src/Controllers/Version3/class-wc-rest-report-reviews-totals-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-reviews-totals-controller.php rename to src/Controllers/Version3/class-wc-rest-report-reviews-totals-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-sales-controller.php b/src/Controllers/Version3/class-wc-rest-report-sales-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-sales-controller.php rename to src/Controllers/Version3/class-wc-rest-report-sales-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-report-top-sellers-controller.php b/src/Controllers/Version3/class-wc-rest-report-top-sellers-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-report-top-sellers-controller.php rename to src/Controllers/Version3/class-wc-rest-report-top-sellers-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-reports-controller.php b/src/Controllers/Version3/class-wc-rest-reports-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-reports-controller.php rename to src/Controllers/Version3/class-wc-rest-reports-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-setting-options-controller.php b/src/Controllers/Version3/class-wc-rest-setting-options-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-setting-options-controller.php rename to src/Controllers/Version3/class-wc-rest-setting-options-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-settings-controller.php b/src/Controllers/Version3/class-wc-rest-settings-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-settings-controller.php rename to src/Controllers/Version3/class-wc-rest-settings-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-shipping-methods-controller.php b/src/Controllers/Version3/class-wc-rest-shipping-methods-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-shipping-methods-controller.php rename to src/Controllers/Version3/class-wc-rest-shipping-methods-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-shipping-zone-locations-controller.php b/src/Controllers/Version3/class-wc-rest-shipping-zone-locations-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-shipping-zone-locations-controller.php rename to src/Controllers/Version3/class-wc-rest-shipping-zone-locations-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-shipping-zone-methods-controller.php b/src/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-shipping-zone-methods-controller.php rename to src/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-shipping-zones-controller-base.php b/src/Controllers/Version3/class-wc-rest-shipping-zones-controller-base.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-shipping-zones-controller-base.php rename to src/Controllers/Version3/class-wc-rest-shipping-zones-controller-base.php diff --git a/src/RestApi/Version3/class-wc-rest-shipping-zones-controller.php b/src/Controllers/Version3/class-wc-rest-shipping-zones-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-shipping-zones-controller.php rename to src/Controllers/Version3/class-wc-rest-shipping-zones-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-system-status-controller.php b/src/Controllers/Version3/class-wc-rest-system-status-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-system-status-controller.php rename to src/Controllers/Version3/class-wc-rest-system-status-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-system-status-tools-controller.php b/src/Controllers/Version3/class-wc-rest-system-status-tools-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-system-status-tools-controller.php rename to src/Controllers/Version3/class-wc-rest-system-status-tools-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-tax-classes-controller.php b/src/Controllers/Version3/class-wc-rest-tax-classes-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-tax-classes-controller.php rename to src/Controllers/Version3/class-wc-rest-tax-classes-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-taxes-controller.php b/src/Controllers/Version3/class-wc-rest-taxes-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-taxes-controller.php rename to src/Controllers/Version3/class-wc-rest-taxes-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-terms-controller.php b/src/Controllers/Version3/class-wc-rest-terms-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-terms-controller.php rename to src/Controllers/Version3/class-wc-rest-terms-controller.php diff --git a/src/RestApi/Version3/class-wc-rest-webhooks-controller.php b/src/Controllers/Version3/class-wc-rest-webhooks-controller.php similarity index 100% rename from src/RestApi/Version3/class-wc-rest-webhooks-controller.php rename to src/Controllers/Version3/class-wc-rest-webhooks-controller.php diff --git a/src/RestApi/Version4/Controllers/AbstractController.php b/src/Controllers/Version4/AbstractController.php similarity index 99% rename from src/RestApi/Version4/Controllers/AbstractController.php rename to src/Controllers/Version4/AbstractController.php index d381bceef54..e073d8d502a 100644 --- a/src/RestApi/Version4/Controllers/AbstractController.php +++ b/src/Controllers/Version4/AbstractController.php @@ -13,7 +13,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/AbstractObjectsController.php b/src/Controllers/Version4/AbstractObjectsController.php similarity index 99% rename from src/RestApi/Version4/Controllers/AbstractObjectsController.php rename to src/Controllers/Version4/AbstractObjectsController.php index 6959d0127b5..047110ffe3e 100644 --- a/src/RestApi/Version4/Controllers/AbstractObjectsController.php +++ b/src/Controllers/Version4/AbstractObjectsController.php @@ -5,7 +5,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/AbstractPostsController.php b/src/Controllers/Version4/AbstractPostsController.php similarity index 99% rename from src/RestApi/Version4/Controllers/AbstractPostsController.php rename to src/Controllers/Version4/AbstractPostsController.php index b6609885d54..c07b7fe09d6 100644 --- a/src/RestApi/Version4/Controllers/AbstractPostsController.php +++ b/src/Controllers/Version4/AbstractPostsController.php @@ -5,7 +5,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/AbstractShippingZonesController.php b/src/Controllers/Version4/AbstractShippingZonesController.php similarity index 98% rename from src/RestApi/Version4/Controllers/AbstractShippingZonesController.php rename to src/Controllers/Version4/AbstractShippingZonesController.php index 348d4a8a4f6..aa10f02f4a0 100644 --- a/src/RestApi/Version4/Controllers/AbstractShippingZonesController.php +++ b/src/Controllers/Version4/AbstractShippingZonesController.php @@ -8,7 +8,7 @@ * @since 3.0.0 */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/AbstractTermsContoller.php b/src/Controllers/Version4/AbstractTermsContoller.php similarity index 99% rename from src/RestApi/Version4/Controllers/AbstractTermsContoller.php rename to src/Controllers/Version4/AbstractTermsContoller.php index 513005002f7..3508b79a5d2 100644 --- a/src/RestApi/Version4/Controllers/AbstractTermsContoller.php +++ b/src/Controllers/Version4/AbstractTermsContoller.php @@ -5,7 +5,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/AdminNotes.php b/src/Controllers/Version4/AdminNotes.php similarity index 99% rename from src/RestApi/Version4/Controllers/AdminNotes.php rename to src/Controllers/Version4/AdminNotes.php index ee39d96d727..17eb739d614 100644 --- a/src/RestApi/Version4/Controllers/AdminNotes.php +++ b/src/Controllers/Version4/AdminNotes.php @@ -7,7 +7,7 @@ * @package WooCommerce Admin/API */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Coupons.php b/src/Controllers/Version4/Coupons.php similarity index 99% rename from src/RestApi/Version4/Controllers/Coupons.php rename to src/Controllers/Version4/Coupons.php index f4c4c9b13ac..a10208c0543 100644 --- a/src/RestApi/Version4/Controllers/Coupons.php +++ b/src/Controllers/Version4/Coupons.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/CustomerDownloads.php b/src/Controllers/Version4/CustomerDownloads.php similarity index 99% rename from src/RestApi/Version4/Controllers/CustomerDownloads.php rename to src/Controllers/Version4/CustomerDownloads.php index 0dcb39cf469..25e94097b04 100644 --- a/src/RestApi/Version4/Controllers/CustomerDownloads.php +++ b/src/Controllers/Version4/CustomerDownloads.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Customers.php b/src/Controllers/Version4/Customers.php similarity index 99% rename from src/RestApi/Version4/Controllers/Customers.php rename to src/Controllers/Version4/Customers.php index 4194b7d8ebf..018c5a6b0ef 100644 --- a/src/RestApi/Version4/Controllers/Customers.php +++ b/src/Controllers/Version4/Customers.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; @@ -440,7 +440,7 @@ class Customers extends AbstractController { * Update a single user. * * @throws \WC_REST_Exception On invalid params. - * + * * @param \WP_REST_Request $request Full details about the request. * @return \WP_Error\WP_REST_Response */ diff --git a/src/RestApi/Version4/Controllers/Data.php b/src/Controllers/Version4/Data.php similarity index 98% rename from src/RestApi/Version4/Controllers/Data.php rename to src/Controllers/Version4/Data.php index bb91d3fa18a..b5e654badbf 100644 --- a/src/RestApi/Version4/Controllers/Data.php +++ b/src/Controllers/Version4/Data.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Data/Continents.php b/src/Controllers/Version4/Data/Continents.php similarity index 98% rename from src/RestApi/Version4/Controllers/Data/Continents.php rename to src/Controllers/Version4/Data/Continents.php index 995196df4e5..69b76280515 100644 --- a/src/RestApi/Version4/Controllers/Data/Continents.php +++ b/src/Controllers/Version4/Data/Continents.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Data; +namespace WooCommerce\RestApi\Controllers\Version4\Data; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Data as DataController; +use \WooCommerce\RestApi\Controllers\Version4\Data as DataController; /** * REST API Data Continents controller class. diff --git a/src/RestApi/Version4/Controllers/Data/Countries.php b/src/Controllers/Version4/Data/Countries.php similarity index 98% rename from src/RestApi/Version4/Controllers/Data/Countries.php rename to src/Controllers/Version4/Data/Countries.php index 8a76ad37789..c1993db8583 100644 --- a/src/RestApi/Version4/Controllers/Data/Countries.php +++ b/src/Controllers/Version4/Data/Countries.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Data; +namespace WooCommerce\RestApi\Controllers\Version4\Data; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Data as DataController; +use \WooCommerce\RestApi\Controllers\Version4\Data as DataController; /** * REST API Data Countries controller class. diff --git a/src/RestApi/Version4/Controllers/Data/Currencies.php b/src/Controllers/Version4/Data/Currencies.php similarity index 98% rename from src/RestApi/Version4/Controllers/Data/Currencies.php rename to src/Controllers/Version4/Data/Currencies.php index f3e5acaa54d..3974edcaeb6 100644 --- a/src/RestApi/Version4/Controllers/Data/Currencies.php +++ b/src/Controllers/Version4/Data/Currencies.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Data; +namespace WooCommerce\RestApi\Controllers\Version4\Data; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Data as DataController; +use \WooCommerce\RestApi\Controllers\Version4\Data as DataController; /** * REST API Data Currencies controller class. diff --git a/src/RestApi/Version4/Controllers/Data/DownloadIPs.php b/src/Controllers/Version4/Data/DownloadIPs.php similarity index 97% rename from src/RestApi/Version4/Controllers/Data/DownloadIPs.php rename to src/Controllers/Version4/Data/DownloadIPs.php index 8e7637d4e67..9d27f037d94 100644 --- a/src/RestApi/Version4/Controllers/Data/DownloadIPs.php +++ b/src/Controllers/Version4/Data/DownloadIPs.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Data; +namespace WooCommerce\RestApi\Controllers\Version4\Data; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Data as DataController; +use \WooCommerce\RestApi\Controllers\Version4\Data as DataController; /** * Data Download IP controller. diff --git a/src/RestApi/Version4/Controllers/Leaderboards.php b/src/Controllers/Version4/Leaderboards.php similarity index 99% rename from src/RestApi/Version4/Controllers/Leaderboards.php rename to src/Controllers/Version4/Leaderboards.php index 7cc3b2d99b2..255e1779418 100644 --- a/src/RestApi/Version4/Controllers/Leaderboards.php +++ b/src/Controllers/Version4/Leaderboards.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/NetworkOrders.php b/src/Controllers/Version4/NetworkOrders.php similarity index 98% rename from src/RestApi/Version4/Controllers/NetworkOrders.php rename to src/Controllers/Version4/NetworkOrders.php index 5c3e5cde7ef..2db3d53916c 100644 --- a/src/RestApi/Version4/Controllers/NetworkOrders.php +++ b/src/Controllers/Version4/NetworkOrders.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/OrderNotes.php b/src/Controllers/Version4/OrderNotes.php similarity index 99% rename from src/RestApi/Version4/Controllers/OrderNotes.php rename to src/Controllers/Version4/OrderNotes.php index af91feec133..ef4bc0c2dae 100644 --- a/src/RestApi/Version4/Controllers/OrderNotes.php +++ b/src/Controllers/Version4/OrderNotes.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; @@ -35,7 +35,7 @@ class OrderNotes extends AbstractController { */ public function register_routes() { register_rest_route( - $this->namespace, + $this->namespace, '/' . $this->rest_base, array( 'args' => array( @@ -68,7 +68,7 @@ class OrderNotes extends AbstractController { ); register_rest_route( - $this->namespace, + $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', array( 'args' => array( diff --git a/src/RestApi/Version4/Controllers/OrderRefunds.php b/src/Controllers/Version4/OrderRefunds.php similarity index 99% rename from src/RestApi/Version4/Controllers/OrderRefunds.php rename to src/Controllers/Version4/OrderRefunds.php index 16af7ef6dba..a8ed226b12b 100644 --- a/src/RestApi/Version4/Controllers/OrderRefunds.php +++ b/src/Controllers/Version4/OrderRefunds.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Orders.php b/src/Controllers/Version4/Orders.php similarity index 99% rename from src/RestApi/Version4/Controllers/Orders.php rename to src/Controllers/Version4/Orders.php index efbdb199951..d1e85b61850 100644 --- a/src/RestApi/Version4/Controllers/Orders.php +++ b/src/Controllers/Version4/Orders.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/PaymentGateways.php b/src/Controllers/Version4/PaymentGateways.php similarity index 99% rename from src/RestApi/Version4/Controllers/PaymentGateways.php rename to src/Controllers/Version4/PaymentGateways.php index 5a1b683820a..74d80d330f4 100644 --- a/src/RestApi/Version4/Controllers/PaymentGateways.php +++ b/src/Controllers/Version4/PaymentGateways.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductAttributeTerms.php b/src/Controllers/Version4/ProductAttributeTerms.php similarity index 99% rename from src/RestApi/Version4/Controllers/ProductAttributeTerms.php rename to src/Controllers/Version4/ProductAttributeTerms.php index bfa6714bef4..eeb20f54edd 100644 --- a/src/RestApi/Version4/Controllers/ProductAttributeTerms.php +++ b/src/Controllers/Version4/ProductAttributeTerms.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductAttributes.php b/src/Controllers/Version4/ProductAttributes.php similarity index 99% rename from src/RestApi/Version4/Controllers/ProductAttributes.php rename to src/Controllers/Version4/ProductAttributes.php index cea3491f897..70f955ea928 100644 --- a/src/RestApi/Version4/Controllers/ProductAttributes.php +++ b/src/Controllers/Version4/ProductAttributes.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductCategories.php b/src/Controllers/Version4/ProductCategories.php similarity index 99% rename from src/RestApi/Version4/Controllers/ProductCategories.php rename to src/Controllers/Version4/ProductCategories.php index 6e7ff08fd3b..76940158244 100644 --- a/src/RestApi/Version4/Controllers/ProductCategories.php +++ b/src/Controllers/Version4/ProductCategories.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductReviews.php b/src/Controllers/Version4/ProductReviews.php similarity index 99% rename from src/RestApi/Version4/Controllers/ProductReviews.php rename to src/Controllers/Version4/ProductReviews.php index 7a52f09481a..1a1b87be436 100644 --- a/src/RestApi/Version4/Controllers/ProductReviews.php +++ b/src/Controllers/Version4/ProductReviews.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductShippingClasses.php b/src/Controllers/Version4/ProductShippingClasses.php similarity index 98% rename from src/RestApi/Version4/Controllers/ProductShippingClasses.php rename to src/Controllers/Version4/ProductShippingClasses.php index d9bc0c8c2de..0df19fc7600 100644 --- a/src/RestApi/Version4/Controllers/ProductShippingClasses.php +++ b/src/Controllers/Version4/ProductShippingClasses.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductTags.php b/src/Controllers/Version4/ProductTags.php similarity index 98% rename from src/RestApi/Version4/Controllers/ProductTags.php rename to src/Controllers/Version4/ProductTags.php index a1491bd3c34..ac4b08c586c 100644 --- a/src/RestApi/Version4/Controllers/ProductTags.php +++ b/src/Controllers/Version4/ProductTags.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ProductVariations.php b/src/Controllers/Version4/ProductVariations.php similarity index 99% rename from src/RestApi/Version4/Controllers/ProductVariations.php rename to src/Controllers/Version4/ProductVariations.php index f65cf24369d..ab0e9e143af 100644 --- a/src/RestApi/Version4/Controllers/ProductVariations.php +++ b/src/Controllers/Version4/ProductVariations.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; @@ -286,7 +286,7 @@ class ProductVariations extends Products { * Set variation image. * * @throws \WC_REST_Exception REST API exceptions. - * + * * @param \WC_Product_Variation $variation Variation instance. * @param array $image Image data. * @return WC_Product_Variation diff --git a/src/RestApi/Version4/Controllers/Products.php b/src/Controllers/Version4/Products.php similarity index 99% rename from src/RestApi/Version4/Controllers/Products.php rename to src/Controllers/Version4/Products.php index 73477850733..1259175b973 100644 --- a/src/RestApi/Version4/Controllers/Products.php +++ b/src/Controllers/Version4/Products.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; @@ -1201,7 +1201,7 @@ class Products extends AbstractObjectsController { * Set product images. * * @throws \WC_REST_Exception REST API exceptions. - * + * * @param WC_Product $product Product instance. * @param array $images Images data. * @return WC_Product diff --git a/src/RestApi/Version4/Controllers/Reports.php b/src/Controllers/Version4/Reports.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports.php rename to src/Controllers/Version4/Reports.php index b187692b9d8..b989bb17dde 100644 --- a/src/RestApi/Version4/Controllers/Reports.php +++ b/src/Controllers/Version4/Reports.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Reports/Categories.php b/src/Controllers/Version4/Reports/Categories.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Categories.php rename to src/Controllers/Version4/Reports/Categories.php index 5d69e501b42..1c8a6d65572 100644 --- a/src/RestApi/Version4/Controllers/Reports/Categories.php +++ b/src/Controllers/Version4/Reports/Categories.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Categories Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/CouponStats.php b/src/Controllers/Version4/Reports/CouponStats.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/CouponStats.php rename to src/Controllers/Version4/Reports/CouponStats.php index 5b5bfdb2365..e837f249bc5 100644 --- a/src/RestApi/Version4/Controllers/Reports/CouponStats.php +++ b/src/Controllers/Version4/Reports/CouponStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API CouponStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Coupons.php b/src/Controllers/Version4/Reports/Coupons.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Coupons.php rename to src/Controllers/Version4/Reports/Coupons.php index b4567d8168b..959e6b3fc2b 100644 --- a/src/RestApi/Version4/Controllers/Reports/Coupons.php +++ b/src/Controllers/Version4/Reports/Coupons.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Coupons Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/CustomerStats.php b/src/Controllers/Version4/Reports/CustomerStats.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/CustomerStats.php rename to src/Controllers/Version4/Reports/CustomerStats.php index def364100b1..cb7af69549d 100644 --- a/src/RestApi/Version4/Controllers/Reports/CustomerStats.php +++ b/src/Controllers/Version4/Reports/CustomerStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API CustomerStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Customers.php b/src/Controllers/Version4/Reports/Customers.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/Customers.php rename to src/Controllers/Version4/Reports/Customers.php index e96c3804a03..8d9dfd89248 100644 --- a/src/RestApi/Version4/Controllers/Reports/Customers.php +++ b/src/Controllers/Version4/Reports/Customers.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Customers Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/DownloadStats.php b/src/Controllers/Version4/Reports/DownloadStats.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/DownloadStats.php rename to src/Controllers/Version4/Reports/DownloadStats.php index 45e23d85e6f..6d660f7b8a7 100644 --- a/src/RestApi/Version4/Controllers/Reports/DownloadStats.php +++ b/src/Controllers/Version4/Reports/DownloadStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API DownloadStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Downloads.php b/src/Controllers/Version4/Reports/Downloads.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/Downloads.php rename to src/Controllers/Version4/Reports/Downloads.php index dff4cc63491..f4828e4d7b8 100644 --- a/src/RestApi/Version4/Controllers/Reports/Downloads.php +++ b/src/Controllers/Version4/Reports/Downloads.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Downloads Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Import.php b/src/Controllers/Version4/Reports/Import.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Import.php rename to src/Controllers/Version4/Reports/Import.php index 10e168e3a53..ea7907617ae 100644 --- a/src/RestApi/Version4/Controllers/Reports/Import.php +++ b/src/Controllers/Version4/Reports/Import.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Import Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/OrderStats.php b/src/Controllers/Version4/Reports/OrderStats.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/OrderStats.php rename to src/Controllers/Version4/Reports/OrderStats.php index 894bde56073..bc3d75b4d6d 100644 --- a/src/RestApi/Version4/Controllers/Reports/OrderStats.php +++ b/src/Controllers/Version4/Reports/OrderStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API OrderStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Orders.php b/src/Controllers/Version4/Reports/Orders.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/Orders.php rename to src/Controllers/Version4/Reports/Orders.php index 622b4a18763..c4c71a12c9e 100644 --- a/src/RestApi/Version4/Controllers/Reports/Orders.php +++ b/src/Controllers/Version4/Reports/Orders.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Orders Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/PerformanceIndicators.php b/src/Controllers/Version4/Reports/PerformanceIndicators.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/PerformanceIndicators.php rename to src/Controllers/Version4/Reports/PerformanceIndicators.php index 7c4dae39174..164b34a2bec 100644 --- a/src/RestApi/Version4/Controllers/Reports/PerformanceIndicators.php +++ b/src/Controllers/Version4/Reports/PerformanceIndicators.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API PerformanceIndicators class. diff --git a/src/RestApi/Version4/Controllers/Reports/ProductStats.php b/src/Controllers/Version4/Reports/ProductStats.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/ProductStats.php rename to src/Controllers/Version4/Reports/ProductStats.php index d68a760e485..caceed9698a 100644 --- a/src/RestApi/Version4/Controllers/Reports/ProductStats.php +++ b/src/Controllers/Version4/Reports/ProductStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API ProductStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Products.php b/src/Controllers/Version4/Reports/Products.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Products.php rename to src/Controllers/Version4/Reports/Products.php index ba420c494ec..fd91702dbc7 100644 --- a/src/RestApi/Version4/Controllers/Reports/Products.php +++ b/src/Controllers/Version4/Reports/Products.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Products Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/RevenueStats.php b/src/Controllers/Version4/Reports/RevenueStats.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/RevenueStats.php rename to src/Controllers/Version4/Reports/RevenueStats.php index 8d58294c2e4..50608095a0f 100644 --- a/src/RestApi/Version4/Controllers/Reports/RevenueStats.php +++ b/src/Controllers/Version4/Reports/RevenueStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API RevenueStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Stock.php b/src/Controllers/Version4/Reports/Stock.php similarity index 99% rename from src/RestApi/Version4/Controllers/Reports/Stock.php rename to src/Controllers/Version4/Reports/Stock.php index 6bcaeb4d4cd..ab9b601b5bc 100644 --- a/src/RestApi/Version4/Controllers/Reports/Stock.php +++ b/src/Controllers/Version4/Reports/Stock.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Stock Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/StockStats.php b/src/Controllers/Version4/Reports/StockStats.php similarity index 96% rename from src/RestApi/Version4/Controllers/Reports/StockStats.php rename to src/Controllers/Version4/Reports/StockStats.php index db704677959..625f3788abf 100644 --- a/src/RestApi/Version4/Controllers/Reports/StockStats.php +++ b/src/Controllers/Version4/Reports/StockStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API StockStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/TaxStats.php b/src/Controllers/Version4/Reports/TaxStats.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/TaxStats.php rename to src/Controllers/Version4/Reports/TaxStats.php index 1c816c4d857..5fc4c61963d 100644 --- a/src/RestApi/Version4/Controllers/Reports/TaxStats.php +++ b/src/Controllers/Version4/Reports/TaxStats.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API TaxesStats Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Taxes.php b/src/Controllers/Version4/Reports/Taxes.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Taxes.php rename to src/Controllers/Version4/Reports/Taxes.php index 9ebc4e29d89..f19b99944d9 100644 --- a/src/RestApi/Version4/Controllers/Reports/Taxes.php +++ b/src/Controllers/Version4/Reports/Taxes.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Taxes Reports class. diff --git a/src/RestApi/Version4/Controllers/Reports/Variations.php b/src/Controllers/Version4/Reports/Variations.php similarity index 98% rename from src/RestApi/Version4/Controllers/Reports/Variations.php rename to src/Controllers/Version4/Reports/Variations.php index 988e40f761e..63a1f6c86ad 100644 --- a/src/RestApi/Version4/Controllers/Reports/Variations.php +++ b/src/Controllers/Version4/Reports/Variations.php @@ -7,11 +7,11 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers\Reports; +namespace WooCommerce\RestApi\Controllers\Version4\Reports; defined( 'ABSPATH' ) || exit; -use \WooCommerce\RestApi\Version4\Controllers\Reports as Reports; +use \WooCommerce\RestApi\Controllers\Version4\Reports as Reports; /** * REST API Variations Reports class. diff --git a/src/RestApi/Version4/Controllers/Settings.php b/src/Controllers/Version4/Settings.php similarity index 99% rename from src/RestApi/Version4/Controllers/Settings.php rename to src/Controllers/Version4/Settings.php index 68aca43c5be..959437f9f2b 100644 --- a/src/RestApi/Version4/Controllers/Settings.php +++ b/src/Controllers/Version4/Settings.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/SettingsOptions.php b/src/Controllers/Version4/SettingsOptions.php similarity index 99% rename from src/RestApi/Version4/Controllers/SettingsOptions.php rename to src/Controllers/Version4/SettingsOptions.php index 20f71ed9db4..dbe2c599acf 100644 --- a/src/RestApi/Version4/Controllers/SettingsOptions.php +++ b/src/Controllers/Version4/SettingsOptions.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ShippingMethods.php b/src/Controllers/Version4/ShippingMethods.php similarity index 99% rename from src/RestApi/Version4/Controllers/ShippingMethods.php rename to src/Controllers/Version4/ShippingMethods.php index 529c2f92d53..a829609dbc6 100644 --- a/src/RestApi/Version4/Controllers/ShippingMethods.php +++ b/src/Controllers/Version4/ShippingMethods.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ShippingZoneLocations.php b/src/Controllers/Version4/ShippingZoneLocations.php similarity index 99% rename from src/RestApi/Version4/Controllers/ShippingZoneLocations.php rename to src/Controllers/Version4/ShippingZoneLocations.php index a6c004695ed..c1f79d92f07 100644 --- a/src/RestApi/Version4/Controllers/ShippingZoneLocations.php +++ b/src/Controllers/Version4/ShippingZoneLocations.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ShippingZoneMethods.php b/src/Controllers/Version4/ShippingZoneMethods.php similarity index 99% rename from src/RestApi/Version4/Controllers/ShippingZoneMethods.php rename to src/Controllers/Version4/ShippingZoneMethods.php index d731ad4f45e..717205ff2a8 100644 --- a/src/RestApi/Version4/Controllers/ShippingZoneMethods.php +++ b/src/Controllers/Version4/ShippingZoneMethods.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/ShippingZones.php b/src/Controllers/Version4/ShippingZones.php similarity index 99% rename from src/RestApi/Version4/Controllers/ShippingZones.php rename to src/Controllers/Version4/ShippingZones.php index 55732940534..1c57fc75133 100644 --- a/src/RestApi/Version4/Controllers/ShippingZones.php +++ b/src/Controllers/Version4/ShippingZones.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/SystemStatus.php b/src/Controllers/Version4/SystemStatus.php similarity index 99% rename from src/RestApi/Version4/Controllers/SystemStatus.php rename to src/Controllers/Version4/SystemStatus.php index e7da5376d68..654b0ccf7bd 100644 --- a/src/RestApi/Version4/Controllers/SystemStatus.php +++ b/src/Controllers/Version4/SystemStatus.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/SystemStatusTools.php b/src/Controllers/Version4/SystemStatusTools.php similarity index 99% rename from src/RestApi/Version4/Controllers/SystemStatusTools.php rename to src/Controllers/Version4/SystemStatusTools.php index 9ec0e03a034..d90f9e72789 100644 --- a/src/RestApi/Version4/Controllers/SystemStatusTools.php +++ b/src/Controllers/Version4/SystemStatusTools.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/TaxClasses.php b/src/Controllers/Version4/TaxClasses.php similarity index 99% rename from src/RestApi/Version4/Controllers/TaxClasses.php rename to src/Controllers/Version4/TaxClasses.php index 724640dd646..770ad1599d6 100644 --- a/src/RestApi/Version4/Controllers/TaxClasses.php +++ b/src/Controllers/Version4/TaxClasses.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Taxes.php b/src/Controllers/Version4/Taxes.php similarity index 99% rename from src/RestApi/Version4/Controllers/Taxes.php rename to src/Controllers/Version4/Taxes.php index ca787b552cc..64741ae8328 100644 --- a/src/RestApi/Version4/Controllers/Taxes.php +++ b/src/Controllers/Version4/Taxes.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; diff --git a/src/RestApi/Version4/Controllers/Webhooks.php b/src/Controllers/Version4/Webhooks.php similarity index 90% rename from src/RestApi/Version4/Controllers/Webhooks.php rename to src/Controllers/Version4/Webhooks.php index e18dab3ff50..c652ad2a951 100644 --- a/src/RestApi/Version4/Controllers/Webhooks.php +++ b/src/Controllers/Version4/Webhooks.php @@ -7,7 +7,7 @@ * @package WooCommerce/RestApi */ -namespace WooCommerce\RestApi\Version4\Controllers; +namespace WooCommerce\RestApi\Controllers\Version4; defined( 'ABSPATH' ) || exit; @@ -35,7 +35,8 @@ class Webhooks extends AbstractController { */ public function register_routes() { register_rest_route( - $this->namespace, '/' . $this->rest_base, + $this->namespace, + '/' . $this->rest_base, array( array( 'methods' => \WP_REST_Server::READABLE, @@ -47,18 +48,21 @@ class Webhooks extends AbstractController { 'methods' => \WP_REST_Server::CREATABLE, '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( - 'topic' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'Webhook topic.', 'woocommerce' ), - ), - 'delivery_url' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'Webhook delivery URL.', 'woocommerce' ), - ), - ) ), + 'args' => array_merge( + $this->get_endpoint_args_for_item_schema( \WP_REST_Server::CREATABLE ), + array( + 'topic' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Webhook topic.', 'woocommerce' ), + ), + 'delivery_url' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Webhook delivery URL.', 'woocommerce' ), + ), + ) + ), ), 'schema' => array( $this, 'get_public_item_schema' ), ), @@ -66,9 +70,10 @@ class Webhooks extends AbstractController { ); register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', + $this->namespace, + '/' . $this->rest_base . '/(?P[\d]+)', array( - 'args' => array( + 'args' => array( 'id' => array( 'description' => __( 'Unique identifier for the resource.', 'woocommerce' ), 'type' => 'integer', @@ -106,7 +111,8 @@ class Webhooks extends AbstractController { ); register_rest_route( - $this->namespace, '/' . $this->rest_base . '/batch', + $this->namespace, + '/' . $this->rest_base . '/batch', array( array( 'methods' => \WP_REST_Server::EDITABLE, @@ -251,13 +257,13 @@ class Webhooks extends AbstractController { $prepared_args['paginate'] = true; // Get the webhooks. - $webhooks = array(); - $data_store = \WC_Data_Store::load( 'webhook' ); - $results = $data_store->search_webhooks( $prepared_args ); - $webhook_ids = $results->webhooks; + $webhooks = array(); + $data_store = \WC_Data_Store::load( 'webhook' ); + $results = $data_store->search_webhooks( $prepared_args ); + $webhook_ids = $results->webhooks; foreach ( $webhook_ids as $webhook_id ) { - $data = $this->prepare_item_for_response( $webhook_id, $request ); + $data = $this->prepare_item_for_response( $webhook_id, $request ); $webhooks[] = $this->prepare_response_for_collection( $data ); } @@ -353,7 +359,7 @@ class Webhooks extends AbstractController { * @param \WP_REST_Request $request Request object. * @param bool $creating True when creating item, false when updating. */ - do_action( "woocommerce_rest_insert_webhook_object", $webhook, $request, true ); + do_action( 'woocommerce_rest_insert_webhook_object', $webhook, $request, true ); $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $webhook->get_id(), $request ); @@ -433,7 +439,7 @@ class Webhooks extends AbstractController { * @param \WP_REST_Request $request Request object. * @param bool $creating True when creating item, false when updating. */ - do_action( "woocommerce_rest_insert_webhook_object", $webhook, $request, false ); + do_action( 'woocommerce_rest_insert_webhook_object', $webhook, $request, false ); $request->set_param( 'context', 'edit' ); $response = $this->prepare_item_for_response( $webhook->get_id(), $request ); @@ -496,7 +502,7 @@ class Webhooks extends AbstractController { * @return \WP_Error|stdClass $data Post object. */ protected function prepare_item_for_database( $request ) { - $data = new \stdClass; + $data = new \stdClass(); // Post ID. if ( isset( $request['id'] ) ) { @@ -545,7 +551,7 @@ class Webhooks extends AbstractController { /** * Prepare a single webhook output for response. * - * @param int $id Webhook ID. + * @param int $id Webhook ID. * @param \WP_REST_Request $request Request object. * @return \WP_REST_Response $response */ @@ -598,7 +604,7 @@ class Webhooks extends AbstractController { */ protected function prepare_links( $id ) { $links = array( - 'self' => array( + 'self' => array( 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $id ) ), ), 'collection' => array( @@ -716,23 +722,23 @@ class Webhooks extends AbstractController { $params['context']['default'] = 'view'; - $params['after'] = array( - 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), - 'type' => 'string', - 'format' => 'date-time', - 'validate_callback' => 'rest_validate_request_arg', + $params['after'] = array( + 'description' => __( 'Limit response to resources published after a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['before'] = array( - 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), - 'type' => 'string', - 'format' => 'date-time', - 'validate_callback' => 'rest_validate_request_arg', + $params['before'] = array( + 'description' => __( 'Limit response to resources published before a given ISO8601 compliant date.', 'woocommerce' ), + 'type' => 'string', + 'format' => 'date-time', + 'validate_callback' => 'rest_validate_request_arg', ); $params['exclude'] = array( 'description' => __( 'Ensure result set excludes specific IDs.', 'woocommerce' ), 'type' => 'array', 'items' => array( - 'type' => 'integer', + 'type' => 'integer', ), 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list', @@ -741,36 +747,36 @@ class Webhooks extends AbstractController { 'description' => __( 'Limit result set to specific ids.', 'woocommerce' ), 'type' => 'array', 'items' => array( - 'type' => 'integer', + 'type' > 'integer', ), 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list', ); - $params['offset'] = array( - 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), - 'type' => 'integer', - 'sanitize_callback' => 'absint', - 'validate_callback' => 'rest_validate_request_arg', + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'woocommerce' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['order'] = array( - 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), - 'type' => 'string', - 'default' => 'desc', - 'enum' => array( 'asc', 'desc' ), - 'validate_callback' => 'rest_validate_request_arg', + $params['order'] = array( + 'description' => __( 'Order sort attribute ascending or descending.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'desc', + 'enum' => array( 'asc', 'desc' ), + 'validate_callback' => 'rest_validate_request_arg', ); $params['orderby'] = array( - 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), - 'type' => 'string', - 'default' => 'date', - 'enum' => array( + 'description' => __( 'Sort collection by object attribute.', 'woocommerce' ), + 'type' => 'string', + 'default' => 'date', + 'enum' => array( 'date', 'id', 'title', ), - 'validate_callback' => 'rest_validate_request_arg', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['status'] = array( + $params['status'] = array( 'default' => 'all', 'description' => __( 'Limit result set to webhooks assigned a specific status.', 'woocommerce' ), 'type' => 'string', diff --git a/src/RestApi/Version4/changelog.md b/src/Controllers/Version4/_changelog.md similarity index 100% rename from src/RestApi/Version4/changelog.md rename to src/Controllers/Version4/_changelog.md diff --git a/src/RestApi.php b/src/RestApi.php deleted file mode 100644 index 3ccfaff8e63..00000000000 --- a/src/RestApi.php +++ /dev/null @@ -1,91 +0,0 @@ -get_rest_namespaces() as $namespace => $namespace_class ) { - $controllers = $namespace_class::get_controllers(); - - foreach ( $controllers as $controller_name => $controller_class ) { - $this->controllers[ $namespace ][ $controller_name ] = new $controller_class(); - $this->controllers[ $namespace ][ $controller_name ]->register_routes(); - } - } - } - - /** - * Get API namespaces - new namespaces should be registered here. - * - * @return array List of Namespaces and Main controller classes. - */ - protected function get_rest_namespaces() { - return apply_filters( - 'woocommerce_rest_api_get_rest_namespaces', - [ - 'wc/v1' => 'WC_REST_Controllers_V1', - 'wc/v2' => 'WC_REST_Controllers_V2', - 'wc/v3' => 'WC_REST_Controllers_V3', - 'wc/v4' => '\WooCommerce\RestApi\Version4\Controllers', - ] - ); - } - - /** - * Get data from a WooCommerce API endpoint. - * - * @param string $endpoint Endpoint. - * @param array $params Params to passwith request. - * @return array|WP_Error - */ - public function get_endpoint_data( $endpoint, $params = array() ) { - $request = new \WP_REST_Request( 'GET', $endpoint ); - - if ( $params ) { - $request->set_query_params( $params ); - } - - $response = \rest_do_request( $request ); - $server = \rest_get_server(); - $json = wp_json_encode( $server->response_to_data( $response, false ) ); - - return json_decode( $json, true ); - } -} diff --git a/src/RestApi/Version1/class-wc-rest-controllers-v1.php b/src/RestApi/Version1/class-wc-rest-controllers-v1.php deleted file mode 100644 index e4f468d4c25..00000000000 --- a/src/RestApi/Version1/class-wc-rest-controllers-v1.php +++ /dev/null @@ -1,43 +0,0 @@ - 'WC_REST_Coupons_V1_Controller', - 'customer-downloads' => 'WC_REST_Customer_Downloads_V1_Controller', - 'customers' => 'WC_REST_Customers_V1_Controller', - 'order-notes' => 'WC_REST_Order_Notes_V1_Controller', - 'order-refunds' => 'WC_REST_Order_Refunds_V1_Controller', - 'orders' => 'WC_REST_Orders_V1_Controller', - 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_V1_Controller', - 'product-attributes' => 'WC_REST_Product_Attributes_V1_Controller', - 'product-categories' => 'WC_REST_Product_Categories_V1_Controller', - 'product-reviews' => 'WC_REST_Product_Reviews_V1_Controller', - 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_V1_Controller', - 'product-tags' => 'WC_REST_Product_Tags_V1_Controller', - 'products' => 'WC_REST_Products_V1_Controller', - 'reports-sales' => 'WC_REST_Report_Sales_V1_Controller', - 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_V1_Controller', - 'reports' => 'WC_REST_Reports_V1_Controller', - 'tax-classes' => 'WC_REST_Tax_Classes_V1_Controller', - 'taxes' => 'WC_REST_Taxes_V1_Controller', - 'webhooks' => 'WC_REST_Webhooks_V1_Controller', - 'webhook-deliveries' => 'WC_REST_Webhook_Deliveries_V1_Controller', - ]; - } -} diff --git a/src/RestApi/Version2/class-wc-rest-controllers-v2.php b/src/RestApi/Version2/class-wc-rest-controllers-v2.php deleted file mode 100644 index 6a1d6a9de63..00000000000 --- a/src/RestApi/Version2/class-wc-rest-controllers-v2.php +++ /dev/null @@ -1,54 +0,0 @@ - 'WC_REST_Coupons_V2_Controller', - 'customer-downloads' => 'WC_REST_Customer_Downloads_V2_Controller', - 'customers' => 'WC_REST_Customers_V2_Controller', - 'network-orders' => 'WC_REST_Network_Orders_V2_Controller', - 'order-notes' => 'WC_REST_Order_Notes_V2_Controller', - 'order-refunds' => 'WC_REST_Order_Refunds_V2_Controller', - 'orders' => 'WC_REST_Orders_V2_Controller', - 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_V2_Controller', - 'product-attributes' => 'WC_REST_Product_Attributes_V2_Controller', - 'product-categories' => 'WC_REST_Product_Categories_V2_Controller', - 'product-reviews' => 'WC_REST_Product_Reviews_V2_Controller', - 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_V2_Controller', - 'product-tags' => 'WC_REST_Product_Tags_V2_Controller', - 'products' => 'WC_REST_Products_V2_Controller', - 'product-variations' => 'WC_REST_Product_Variations_V2_Controller', - 'reports-sales' => 'WC_REST_Report_Sales_V2_Controller', - 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_V2_Controller', - 'reports' => 'WC_REST_Reports_V2_Controller', - 'settings' => 'WC_REST_Settings_V2_Controller', - 'settings-options' => 'WC_REST_Setting_Options_V2_Controller', - 'shipping-zones' => 'WC_REST_Shipping_Zones_V2_Controller', - 'shipping-zone-locations' => 'WC_REST_Shipping_Zone_Locations_V2_Controller', - 'shipping-zone-methods' => 'WC_REST_Shipping_Zone_Methods_V2_Controller', - 'tax-classes' => 'WC_REST_Tax_Classes_V2_Controller', - 'taxes' => 'WC_REST_Taxes_V2_Controller', - 'webhooks' => 'WC_REST_Webhooks_V2_Controller', - 'webhook-deliveries' => 'WC_REST_Webhook_Deliveries_V2_Controller', - 'system-status' => 'WC_REST_System_Status_V2_Controller', - 'system-status-tools' => 'WC_REST_System_Status_Tools_V2_Controller', - 'shipping-methods' => 'WC_REST_Shipping_Methods_V2_Controller', - 'payment-gateways' => 'WC_REST_Payment_Gateways_V2_Controller', - ]; - } -} diff --git a/src/RestApi/Version3/class-wc-rest-controllers-v3.php b/src/RestApi/Version3/class-wc-rest-controllers-v3.php deleted file mode 100644 index 50f968afa22..00000000000 --- a/src/RestApi/Version3/class-wc-rest-controllers-v3.php +++ /dev/null @@ -1,62 +0,0 @@ - 'WC_REST_Coupons_Controller', - 'customer-downloads' => 'WC_REST_Customer_Downloads_Controller', - 'customers' => 'WC_REST_Customers_Controller', - 'network-orders' => 'WC_REST_Network_Orders_Controller', - 'order-notes' => 'WC_REST_Order_Notes_Controller', - 'order-refunds' => 'WC_REST_Order_Refunds_Controller', - 'orders' => 'WC_REST_Orders_Controller', - 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_Controller', - 'product-attributes' => 'WC_REST_Product_Attributes_Controller', - 'product-categories' => 'WC_REST_Product_Categories_Controller', - 'product-reviews' => 'WC_REST_Product_Reviews_Controller', - 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_Controller', - 'product-tags' => 'WC_REST_Product_Tags_Controller', - 'products' => 'WC_REST_Products_Controller', - 'product-variations' => 'WC_REST_Product_Variations_Controller', - 'reports-sales' => 'WC_REST_Report_Sales_Controller', - 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_Controller', - 'reports-orders-totals' => 'WC_REST_Report_Orders_Totals_Controller', - 'reports-products-totals' => 'WC_REST_Report_Products_Totals_Controller', - 'reports-customers-totals' => 'WC_REST_Report_Customers_Totals_Controller', - 'reports-coupons-totals' => 'WC_REST_Report_Coupons_Totals_Controller', - 'reports-reviews-totals' => 'WC_REST_Report_Reviews_Totals_Controller', - 'reports' => 'WC_REST_Reports_Controller', - 'settings' => 'WC_REST_Settings_Controller', - 'settings-options' => 'WC_REST_Setting_Options_Controller', - 'shipping-zones' => 'WC_REST_Shipping_Zones_Controller', - 'shipping-zone-locations' => 'WC_REST_Shipping_Zone_Locations_Controller', - 'shipping-zone-methods' => 'WC_REST_Shipping_Zone_Methods_Controller', - 'tax-classes' => 'WC_REST_Tax_Classes_Controller', - 'taxes' => 'WC_REST_Taxes_Controller', - 'webhooks' => 'WC_REST_Webhooks_Controller', - 'system-status' => 'WC_REST_System_Status_Controller', - 'system-status-tools' => 'WC_REST_System_Status_Tools_Controller', - 'shipping-methods' => 'WC_REST_Shipping_Methods_Controller', - 'payment-gateways' => 'WC_REST_Payment_Gateways_Controller', - 'data' => 'WC_REST_Data_Controller', - 'data-continents' => 'WC_REST_Data_Continents_Controller', - 'data-countries' => 'WC_REST_Data_Countries_Controller', - 'data-currencies' => 'WC_REST_Data_Currencies_Controller', - ]; - } -} diff --git a/src/RestApi/Version4/Controllers.php b/src/RestApi/Version4/Controllers.php deleted file mode 100644 index 703a3ee0b54..00000000000 --- a/src/RestApi/Version4/Controllers.php +++ /dev/null @@ -1,87 +0,0 @@ - __NAMESPACE__ . '\Controllers\Coupons', - 'customer-downloads' => __NAMESPACE__ . '\Controllers\CustomerDownloads', - 'customers' => __NAMESPACE__ . '\Controllers\Customers', - 'data' => __NAMESPACE__ . '\Controllers\Data', - 'data-continents' => __NAMESPACE__ . '\Controllers\Data\Continents', - 'data-countries' => __NAMESPACE__ . '\Controllers\Data\Countries', - 'data-currencies' => __NAMESPACE__ . '\Controllers\Data\Currencies', - 'data-download-ips' => __NAMESPACE__ . '\Controllers\Data\DownloadIPs', - 'leaderboards' => __NAMESPACE__ . '\Controllers\Leaderboards', - 'network-orders' => __NAMESPACE__ . '\Controllers\NetworkOrders', - 'order-notes' => __NAMESPACE__ . '\Controllers\OrderNotes', - 'order-refunds' => __NAMESPACE__ . '\Controllers\OrderRefunds', - 'orders' => __NAMESPACE__ . '\Controllers\Orders', - 'payment-gateways' => __NAMESPACE__ . '\Controllers\PaymentGateways', - 'product-attributes' => __NAMESPACE__ . '\Controllers\ProductAttributes', - 'product-attribute-terms' => __NAMESPACE__ . '\Controllers\ProductAttributeTerms', - 'product-categories' => __NAMESPACE__ . '\Controllers\ProductCategories', - 'product-reviews' => __NAMESPACE__ . '\Controllers\ProductReviews', - 'products' => __NAMESPACE__ . '\Controllers\Products', - 'product-shipping-classes' => __NAMESPACE__ . '\Controllers\ProductShippingClasses', - 'product-tags' => __NAMESPACE__ . '\Controllers\ProductTags', - 'product-variations' => __NAMESPACE__ . '\Controllers\ProductVariations', - 'reports' => __NAMESPACE__ . '\Controllers\Reports', - 'settings' => __NAMESPACE__ . '\Controllers\Settings', - 'settings-options' => __NAMESPACE__ . '\Controllers\SettingsOptions', - 'shipping-methods' => __NAMESPACE__ . '\Controllers\ShippingMethods', - 'shipping-zone-locations' => __NAMESPACE__ . '\Controllers\ShippingZoneLocations', - 'shipping-zone-methods' => __NAMESPACE__ . '\Controllers\ShippingZoneMethods', - 'shipping-zones' => __NAMESPACE__ . '\Controllers\ShippingZones', - 'system-status' => __NAMESPACE__ . '\Controllers\SystemStatus', - 'system-status-tools' => __NAMESPACE__ . '\Controllers\SystemStatusTools', - 'tax-classes' => __NAMESPACE__ . '\Controllers\TaxClasses', - 'taxes' => __NAMESPACE__ . '\Controllers\Taxes', - 'webhooks' => __NAMESPACE__ . '\Controllers\Webhooks', - ]; - - if ( class_exists( '\WC_Admin_Note' ) ) { - $controllers['admin-notes'] = __NAMESPACE__ . '\Controllers\AdminNotes'; - } - - if ( class_exists( '\WC_Admin_Reports_Sync' ) ) { - $controllers['reports-categories'] = __NAMESPACE__ . '\Controllers\Reports\Categories'; - $controllers['reports-coupons'] = __NAMESPACE__ . '\Controllers\Reports\Coupons'; - $controllers['reports-coupon-stats'] = __NAMESPACE__ . '\Controllers\Reports\CouponStats'; - $controllers['reports-customers'] = __NAMESPACE__ . '\Controllers\Reports\Customers'; - $controllers['reports-customer-stats'] = __NAMESPACE__ . '\Controllers\Reports\CustomerStats'; - $controllers['reports-downloads'] = __NAMESPACE__ . '\Controllers\Reports\Downloads'; - $controllers['reports-download-stats'] = __NAMESPACE__ . '\Controllers\Reports\DownloadStats'; - $controllers['reports-import'] = __NAMESPACE__ . '\Controllers\Reports\Import'; - $controllers['reports-orders'] = __NAMESPACE__ . '\Controllers\Reports\Orders'; - $controllers['reports-order-stats'] = __NAMESPACE__ . '\Controllers\Reports\OrderStats'; - $controllers['reports-performance-indicators'] = __NAMESPACE__ . '\Controllers\Reports\PerformanceIndicators'; - $controllers['reports-products'] = __NAMESPACE__ . '\Controllers\Reports\Products'; - $controllers['reports-product-stats'] = __NAMESPACE__ . '\Controllers\Reports\ProductStats'; - $controllers['reports-revenue-stats'] = __NAMESPACE__ . '\Controllers\Reports\RevenueStats'; - $controllers['reports-stock'] = __NAMESPACE__ . '\Controllers\Reports\Stock'; - $controllers['reports-stock-stats'] = __NAMESPACE__ . '\Controllers\Reports\StockStats'; - $controllers['reports-taxes'] = __NAMESPACE__ . '\Controllers\Reports\Taxes'; - $controllers['reports-tax-stats'] = __NAMESPACE__ . '\Controllers\Reports\TaxStats'; - $controllers['reports-variations'] = __NAMESPACE__ . '\Controllers\Reports\Variations'; - } - - return $controllers; - } -} diff --git a/src/Server.php b/src/Server.php new file mode 100644 index 00000000000..19164810338 --- /dev/null +++ b/src/Server.php @@ -0,0 +1,282 @@ +get_rest_namespaces() as $namespace => $controllers ) { + foreach ( $controllers as $controller_name => $controller_class ) { + $this->controllers[ $namespace ][ $controller_name ] = new $controller_class(); + $this->controllers[ $namespace ][ $controller_name ]->register_routes(); + } + } + } + + /** + * Get data from a WooCommerce API endpoint. + * + * @param string $endpoint Endpoint. + * @param array $params Params to passwith request. + * @return array|WP_Error + */ + public function get_endpoint_data( $endpoint, $params = array() ) { + $request = new \WP_REST_Request( 'GET', $endpoint ); + + if ( $params ) { + $request->set_query_params( $params ); + } + + $response = \rest_do_request( $request ); + $server = \rest_get_server(); + $json = wp_json_encode( $server->response_to_data( $response, false ) ); + + return json_decode( $json, true ); + } + + /** + * Get API namespaces - new namespaces should be registered here. + * + * @return array List of Namespaces and Main controller classes. + */ + protected function get_rest_namespaces() { + return apply_filters( + 'woocommerce_rest_api_get_rest_namespaces', + [ + 'wc/v1' => $this->get_v1_controllers(), + 'wc/v2' => $this->get_v2_controllers(), + 'wc/v3' => $this->get_v3_controllers(), + 'wc/v4' => $this->get_v4_controllers(), + ] + ); + } + + /** + * List of controllers in the wc/v1 namespace. + * + * @return array + */ + protected function get_v1_controllers() { + return [ + 'coupons' => 'WC_REST_Coupons_V1_Controller', + 'customer-downloads' => 'WC_REST_Customer_Downloads_V1_Controller', + 'customers' => 'WC_REST_Customers_V1_Controller', + 'order-notes' => 'WC_REST_Order_Notes_V1_Controller', + 'order-refunds' => 'WC_REST_Order_Refunds_V1_Controller', + 'orders' => 'WC_REST_Orders_V1_Controller', + 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_V1_Controller', + 'product-attributes' => 'WC_REST_Product_Attributes_V1_Controller', + 'product-categories' => 'WC_REST_Product_Categories_V1_Controller', + 'product-reviews' => 'WC_REST_Product_Reviews_V1_Controller', + 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_V1_Controller', + 'product-tags' => 'WC_REST_Product_Tags_V1_Controller', + 'products' => 'WC_REST_Products_V1_Controller', + 'reports-sales' => 'WC_REST_Report_Sales_V1_Controller', + 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_V1_Controller', + 'reports' => 'WC_REST_Reports_V1_Controller', + 'tax-classes' => 'WC_REST_Tax_Classes_V1_Controller', + 'taxes' => 'WC_REST_Taxes_V1_Controller', + 'webhooks' => 'WC_REST_Webhooks_V1_Controller', + 'webhook-deliveries' => 'WC_REST_Webhook_Deliveries_V1_Controller', + ]; + } + + /** + * List of controllers in the wc/v2 namespace. + * + * @return array + */ + protected function get_v2_controllers() { + return [ + 'coupons' => 'WC_REST_Coupons_V2_Controller', + 'customer-downloads' => 'WC_REST_Customer_Downloads_V2_Controller', + 'customers' => 'WC_REST_Customers_V2_Controller', + 'network-orders' => 'WC_REST_Network_Orders_V2_Controller', + 'order-notes' => 'WC_REST_Order_Notes_V2_Controller', + 'order-refunds' => 'WC_REST_Order_Refunds_V2_Controller', + 'orders' => 'WC_REST_Orders_V2_Controller', + 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_V2_Controller', + 'product-attributes' => 'WC_REST_Product_Attributes_V2_Controller', + 'product-categories' => 'WC_REST_Product_Categories_V2_Controller', + 'product-reviews' => 'WC_REST_Product_Reviews_V2_Controller', + 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_V2_Controller', + 'product-tags' => 'WC_REST_Product_Tags_V2_Controller', + 'products' => 'WC_REST_Products_V2_Controller', + 'product-variations' => 'WC_REST_Product_Variations_V2_Controller', + 'reports-sales' => 'WC_REST_Report_Sales_V2_Controller', + 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_V2_Controller', + 'reports' => 'WC_REST_Reports_V2_Controller', + 'settings' => 'WC_REST_Settings_V2_Controller', + 'settings-options' => 'WC_REST_Setting_Options_V2_Controller', + 'shipping-zones' => 'WC_REST_Shipping_Zones_V2_Controller', + 'shipping-zone-locations' => 'WC_REST_Shipping_Zone_Locations_V2_Controller', + 'shipping-zone-methods' => 'WC_REST_Shipping_Zone_Methods_V2_Controller', + 'tax-classes' => 'WC_REST_Tax_Classes_V2_Controller', + 'taxes' => 'WC_REST_Taxes_V2_Controller', + 'webhooks' => 'WC_REST_Webhooks_V2_Controller', + 'webhook-deliveries' => 'WC_REST_Webhook_Deliveries_V2_Controller', + 'system-status' => 'WC_REST_System_Status_V2_Controller', + 'system-status-tools' => 'WC_REST_System_Status_Tools_V2_Controller', + 'shipping-methods' => 'WC_REST_Shipping_Methods_V2_Controller', + 'payment-gateways' => 'WC_REST_Payment_Gateways_V2_Controller', + ]; + } + + /** + * List of controllers in the wc/v3 namespace. + * + * @return array + */ + protected function get_v3_controllers() { + return [ + 'coupons' => 'WC_REST_Coupons_Controller', + 'customer-downloads' => 'WC_REST_Customer_Downloads_Controller', + 'customers' => 'WC_REST_Customers_Controller', + 'network-orders' => 'WC_REST_Network_Orders_Controller', + 'order-notes' => 'WC_REST_Order_Notes_Controller', + 'order-refunds' => 'WC_REST_Order_Refunds_Controller', + 'orders' => 'WC_REST_Orders_Controller', + 'product-attribute-terms' => 'WC_REST_Product_Attribute_Terms_Controller', + 'product-attributes' => 'WC_REST_Product_Attributes_Controller', + 'product-categories' => 'WC_REST_Product_Categories_Controller', + 'product-reviews' => 'WC_REST_Product_Reviews_Controller', + 'product-shipping-classes' => 'WC_REST_Product_Shipping_Classes_Controller', + 'product-tags' => 'WC_REST_Product_Tags_Controller', + 'products' => 'WC_REST_Products_Controller', + 'product-variations' => 'WC_REST_Product_Variations_Controller', + 'reports-sales' => 'WC_REST_Report_Sales_Controller', + 'reports-top-sellers' => 'WC_REST_Report_Top_Sellers_Controller', + 'reports-orders-totals' => 'WC_REST_Report_Orders_Totals_Controller', + 'reports-products-totals' => 'WC_REST_Report_Products_Totals_Controller', + 'reports-customers-totals' => 'WC_REST_Report_Customers_Totals_Controller', + 'reports-coupons-totals' => 'WC_REST_Report_Coupons_Totals_Controller', + 'reports-reviews-totals' => 'WC_REST_Report_Reviews_Totals_Controller', + 'reports' => 'WC_REST_Reports_Controller', + 'settings' => 'WC_REST_Settings_Controller', + 'settings-options' => 'WC_REST_Setting_Options_Controller', + 'shipping-zones' => 'WC_REST_Shipping_Zones_Controller', + 'shipping-zone-locations' => 'WC_REST_Shipping_Zone_Locations_Controller', + 'shipping-zone-methods' => 'WC_REST_Shipping_Zone_Methods_Controller', + 'tax-classes' => 'WC_REST_Tax_Classes_Controller', + 'taxes' => 'WC_REST_Taxes_Controller', + 'webhooks' => 'WC_REST_Webhooks_Controller', + 'system-status' => 'WC_REST_System_Status_Controller', + 'system-status-tools' => 'WC_REST_System_Status_Tools_Controller', + 'shipping-methods' => 'WC_REST_Shipping_Methods_Controller', + 'payment-gateways' => 'WC_REST_Payment_Gateways_Controller', + 'data' => 'WC_REST_Data_Controller', + 'data-continents' => 'WC_REST_Data_Continents_Controller', + 'data-countries' => 'WC_REST_Data_Countries_Controller', + 'data-currencies' => 'WC_REST_Data_Currencies_Controller', + ]; + } + + /** + * List of controllers in the wc/v4 namespace. + * + * @return array + */ + protected function get_v4_controllers() { + $namespace = __NAMESPACE__ . '\\Controllers\\Version4\\'; + $controllers = [ + 'coupons' => $namespace . 'Coupons', + 'customer-downloads' => $namespace . 'CustomerDownloads', + 'customers' => $namespace . 'Customers', + 'data' => $namespace . 'Data', + 'data-continents' => $namespace . 'Data\Continents', + 'data-countries' => $namespace . 'Data\Countries', + 'data-currencies' => $namespace . 'Data\Currencies', + 'data-download-ips' => $namespace . 'Data\DownloadIPs', + 'leaderboards' => $namespace . 'Leaderboards', + 'network-orders' => $namespace . 'NetworkOrders', + 'order-notes' => $namespace . 'OrderNotes', + 'order-refunds' => $namespace . 'OrderRefunds', + 'orders' => $namespace . 'Orders', + 'payment-gateways' => $namespace . 'PaymentGateways', + 'product-attributes' => $namespace . 'ProductAttributes', + 'product-attribute-terms' => $namespace . 'ProductAttributeTerms', + 'product-categories' => $namespace . 'ProductCategories', + 'product-reviews' => $namespace . 'ProductReviews', + 'products' => $namespace . 'Products', + 'product-shipping-classes' => $namespace . 'ProductShippingClasses', + 'product-tags' => $namespace . 'ProductTags', + 'product-variations' => $namespace . 'ProductVariations', + 'reports' => $namespace . 'Reports', + 'settings' => $namespace . 'Settings', + 'settings-options' => $namespace . 'SettingsOptions', + 'shipping-methods' => $namespace . 'ShippingMethods', + 'shipping-zone-locations' => $namespace . 'ShippingZoneLocations', + 'shipping-zone-methods' => $namespace . 'ShippingZoneMethods', + 'shipping-zones' => $namespace . 'ShippingZones', + 'system-status' => $namespace . 'SystemStatus', + 'system-status-tools' => $namespace . 'SystemStatusTools', + 'tax-classes' => $namespace . 'TaxClasses', + 'taxes' => $namespace . 'Taxes', + 'webhooks' => $namespace . 'Webhooks', + ]; + + if ( class_exists( '\WC_Admin_Note' ) ) { + $controllers['admin-notes'] = $namespace . 'AdminNotes'; + } + + if ( class_exists( '\WC_Admin_Reports_Sync' ) ) { + $controllers['reports-categories'] = $namespace . 'Reports\Categories'; + $controllers['reports-coupons'] = $namespace . 'Reports\Coupons'; + $controllers['reports-coupon-stats'] = $namespace . 'Reports\CouponStats'; + $controllers['reports-customers'] = $namespace . 'Reports\Customers'; + $controllers['reports-customer-stats'] = $namespace . 'Reports\CustomerStats'; + $controllers['reports-downloads'] = $namespace . 'Reports\Downloads'; + $controllers['reports-download-stats'] = $namespace . 'Reports\DownloadStats'; + $controllers['reports-import'] = $namespace . 'Reports\Import'; + $controllers['reports-orders'] = $namespace . 'Reports\Orders'; + $controllers['reports-order-stats'] = $namespace . 'Reports\OrderStats'; + $controllers['reports-performance-indicators'] = $namespace . 'Reports\PerformanceIndicators'; + $controllers['reports-products'] = $namespace . 'Reports\Products'; + $controllers['reports-product-stats'] = $namespace . 'Reports\ProductStats'; + $controllers['reports-revenue-stats'] = $namespace . 'Reports\RevenueStats'; + $controllers['reports-stock'] = $namespace . 'Reports\Stock'; + $controllers['reports-stock-stats'] = $namespace . 'Reports\StockStats'; + $controllers['reports-taxes'] = $namespace . 'Reports\Taxes'; + $controllers['reports-tax-stats'] = $namespace . 'Reports\TaxStats'; + $controllers['reports-variations'] = $namespace . 'Reports\Variations'; + } + + return $controllers; + } +} diff --git a/src/Utilities/SingletonTrait.php b/src/Utilities/SingletonTrait.php index e39c1e35998..e51b76f4b59 100644 --- a/src/Utilities/SingletonTrait.php +++ b/src/Utilities/SingletonTrait.php @@ -2,12 +2,10 @@ /** * Abstract singleton class. * - * TODO: move to core? - * * @package WooCommerce/Utilities */ -namespace WooCommerce\Utilities; +namespace WooCommerce\RestApi\Utilities; /** * Singleton trait. diff --git a/unit-tests/Bootstrap.php b/unit-tests/Bootstrap.php index bab9057189e..747afe884eb 100755 --- a/unit-tests/Bootstrap.php +++ b/unit-tests/Bootstrap.php @@ -8,7 +8,7 @@ namespace WooCommerce\RestApi\UnitTests; require __DIR__ . '/../src/Utilities/SingletonTrait.php'; -use WooCommerce\Utilities\SingletonTrait; +use WooCommerce\RestApi\Utilities\SingletonTrait; class Bootstrap { use SingletonTrait; @@ -33,7 +33,7 @@ class Bootstrap { * @var string */ protected $wc_tests_dir; - + /** * This plugin directory. * @@ -79,15 +79,6 @@ class Bootstrap { return dirname( __FILE__ ); } - /** - * Does WC Admin exist? - * - * @return boolean - */ - protected function wc_admin_exists() { - return file_exists( $this->plugins_dir . '/woocommerce-admin/woocommerce-admin.php' ); - } - /** * Setup hooks. */ @@ -98,10 +89,6 @@ class Bootstrap { \tests_add_filter( 'muplugins_loaded', function() { require_once $this->plugins_dir . '/woocommerce/woocommerce.php'; require_once $this->plugin_dir . '/woocommerce-rest-api.php'; - - if ( $this->wc_admin_exists() ) { - require_once $this->plugins_dir . '/woocommerce-admin/woocommerce-admin.php'; - } } ); \tests_add_filter( 'setup_theme', function() { @@ -113,13 +100,6 @@ class Bootstrap { \WC_Install::install(); - if ( $this->wc_admin_exists() ) { - echo esc_html( 'Installing WooCommerce Admin...' . PHP_EOL ); - require_once $this->plugins_dir . '/woocommerce-admin/includes/class-wc-admin-install.php'; - \WC_Admin_Install::create_tables(); - \WC_Admin_Install::create_events(); - } - $GLOBALS['wp_roles'] = null; // WPCS: override ok. \wp_roles(); } ); diff --git a/version.php b/version.php index 7299ee74106..e26da460584 100644 --- a/version.php +++ b/version.php @@ -5,4 +5,4 @@ * @package WooCommerce/RestApi */ -return '1.1.1'; +return '1.0.0';