PSR-4ify the report exporter classes.
This commit is contained in:
parent
ca68769205
commit
ce7267b198
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
use \Automattic\WooCommerce\Admin\WC_Admin_Report_Exporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports Export controller.
|
* Reports Export controller.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* @package WooCommerce/Export
|
* @package WooCommerce/Export
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Automattic\WooCommerce\Admin;
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +21,7 @@ if ( ! class_exists( 'WC_CSV_Batch_Exporter', false ) ) {
|
||||||
/**
|
/**
|
||||||
* WC_Admin_Report_CSV_Exporter Class.
|
* WC_Admin_Report_CSV_Exporter Class.
|
||||||
*/
|
*/
|
||||||
class WC_Admin_Report_CSV_Exporter extends WC_CSV_Batch_Exporter {
|
class WC_Admin_Report_CSV_Exporter extends \WC_CSV_Batch_Exporter {
|
||||||
/**
|
/**
|
||||||
* Type of report being exported.
|
* Type of report being exported.
|
||||||
*
|
*
|
||||||
|
@ -102,15 +104,15 @@ class WC_Admin_Report_CSV_Exporter extends WC_CSV_Batch_Exporter {
|
||||||
*/
|
*/
|
||||||
protected function map_report_controller() {
|
protected function map_report_controller() {
|
||||||
$controller_map = array(
|
$controller_map = array(
|
||||||
'products' => 'WC_Admin_REST_Reports_Products_Controller',
|
'products' => '\WC_Admin_REST_Reports_Products_Controller',
|
||||||
'variations' => 'WC_Admin_REST_Reports_Variations_Controller',
|
'variations' => '\WC_Admin_REST_Reports_Variations_Controller',
|
||||||
'orders' => 'WC_Admin_REST_Reports_Orders_Controller',
|
'orders' => '\WC_Admin_REST_Reports_Orders_Controller',
|
||||||
'categories' => 'WC_Admin_REST_Reports_Categories_Controller',
|
'categories' => '\WC_Admin_REST_Reports_Categories_Controller',
|
||||||
'taxes' => 'WC_Admin_REST_Reports_Taxes_Controller',
|
'taxes' => '\WC_Admin_REST_Reports_Taxes_Controller',
|
||||||
'coupons' => 'WC_Admin_REST_Reports_Coupons_Controller',
|
'coupons' => '\WC_Admin_REST_Reports_Coupons_Controller',
|
||||||
'stock' => 'WC_Admin_REST_Reports_Stock_Controller',
|
'stock' => '\WC_Admin_REST_Reports_Stock_Controller',
|
||||||
'downloads' => 'WC_Admin_REST_Reports_Downloads_Controller',
|
'downloads' => '\WC_Admin_REST_Reports_Downloads_Controller',
|
||||||
'customers' => 'WC_Admin_REST_Reports_Customers_Controller',
|
'customers' => '\WC_Admin_REST_Reports_Customers_Controller',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( isset( $controller_map[ $this->report_type ] ) ) {
|
if ( isset( $controller_map[ $this->report_type ] ) ) {
|
||||||
|
@ -175,7 +177,7 @@ class WC_Admin_Report_CSV_Exporter extends WC_CSV_Batch_Exporter {
|
||||||
* Prepare data for export.
|
* Prepare data for export.
|
||||||
*/
|
*/
|
||||||
public function prepare_data_to_export() {
|
public function prepare_data_to_export() {
|
||||||
$request = new WP_REST_Request( 'GET', "/wc/v4/reports/{$this->report_type}" );
|
$request = new \WP_REST_Request( 'GET', "/wc/v4/reports/{$this->report_type}" );
|
||||||
$params = $this->controller->get_collection_params();
|
$params = $this->controller->get_collection_params();
|
||||||
$defaults = array();
|
$defaults = array();
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
* @package WooCommerce/Export
|
* @package WooCommerce/Export
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Automattic\WooCommerce\Admin;
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) {
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +95,7 @@ class WC_Admin_Report_Exporter {
|
||||||
$report_batch_args = array( $export_id, $report_type, $report_args );
|
$report_batch_args = array( $export_id, $report_type, $report_args );
|
||||||
|
|
||||||
if ( 0 < $num_batches ) {
|
if ( 0 < $num_batches ) {
|
||||||
WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, self::REPORT_EXPORT_ACTION, $report_batch_args );
|
\WC_Admin_Reports_Sync::queue_batches( 1, $num_batches, self::REPORT_EXPORT_ACTION, $report_batch_args );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $total_rows;
|
return $total_rows;
|
|
@ -5,6 +5,8 @@
|
||||||
* @package WooCommerce\Tests\Coupons
|
* @package WooCommerce\Tests\Coupons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use \Automattic\WooCommerce\Admin\WC_Admin_Report_CSV_Exporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class WC_Tests_Reports_Coupons
|
* Class WC_Tests_Reports_Coupons
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,6 +24,7 @@ use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Historical_Data;
|
||||||
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Order_Milestones;
|
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Order_Milestones;
|
||||||
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Welcome_Message;
|
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Welcome_Message;
|
||||||
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Woo_Subscriptions_Notes;
|
use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Woo_Subscriptions_Notes;
|
||||||
|
use Automattic\WooCommerce\Admin\WC_Admin_Report_Exporter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autoload packages.
|
* Autoload packages.
|
||||||
|
|
Loading…
Reference in New Issue