Move src/Schedulers/* to src-internal/Admin/Schedulers (https://github.com/woocommerce/woocommerce-admin/pull/8316)
* Add psr-4 for the internal classes -- this is a temp. changes. We should remove it once we completely merge to the core * Register class aliases * Move WcPayPromotion classes to the internal * Ignore namespace PHP CS issue * Make features/WcPayPromotion internal * Added src-internal directory for Automattic\WooCommerce\Internal\Admin namespace * Moved src/Features/WcPayPromotion to src-internal/Admin/WcPayPromotion * Add phpcs rules for src-internal * Remove phpcs:ignoreFile * Update letter case to make it PSR4 compatible * Fix letter cases * Move the alias array into the function * Rename WcPayPromotion to WCPayPromotion (letter case update) * Include src-internal * Update letter case * Make src/Schedulers/* internal, except the SchedulerTraits * Add @internal comment tag * Clean up incorrect import * Remove unused import
This commit is contained in:
parent
ce0f73aa9b
commit
aa554fb1e3
|
@ -3,13 +3,12 @@
|
|||
* Customer syncing related functions and actions.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Schedulers;
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Schedulers;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \Automattic\WooCommerce\Admin\API\Reports\Cache as ReportsCache;
|
||||
use \Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore as CustomersDataStore;
|
||||
use \Automattic\WooCommerce\Admin\Schedulers\OrdersScheduler;
|
||||
|
||||
/**
|
||||
* CustomersScheduler Class.
|
||||
|
@ -24,6 +23,8 @@ class CustomersScheduler extends ImportScheduler {
|
|||
|
||||
/**
|
||||
* Attach customer lookup update hooks.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function init() {
|
||||
add_action( 'woocommerce_new_customer', array( __CLASS__, 'schedule_import' ) );
|
||||
|
@ -40,6 +41,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Add customer dependencies.
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public static function get_dependencies() {
|
||||
|
@ -53,6 +55,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Get the customer IDs and total count that need to be synced.
|
||||
*
|
||||
* @internal
|
||||
* @param int $limit Number of records to retrieve.
|
||||
* @param int $page Page number.
|
||||
* @param int|bool $days Number of days prior to current date to limit search results.
|
||||
|
@ -94,6 +97,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
*
|
||||
* Meant to be hooked into 'pre_user_query' action.
|
||||
*
|
||||
* @internal
|
||||
* @param WP_User_Query $wp_user_query WP_User_Query to modify.
|
||||
*/
|
||||
public static function exclude_existing_customers_from_query( $wp_user_query ) {
|
||||
|
@ -108,6 +112,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Get total number of rows imported.
|
||||
*
|
||||
* @internal
|
||||
* @return int
|
||||
*/
|
||||
public static function get_total_imported() {
|
||||
|
@ -119,6 +124,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
* Get all available scheduling actions.
|
||||
* Used to determine action hook names and clear events.
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public static function get_scheduler_actions() {
|
||||
|
@ -131,6 +137,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Schedule import.
|
||||
*
|
||||
* @internal
|
||||
* @param int $user_id User ID.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -142,6 +149,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
* Schedule an import if the "last active" meta value was changed.
|
||||
* Function expects to be hooked into the `updated_user_meta` action.
|
||||
*
|
||||
* @internal
|
||||
* @param int $meta_id ID of updated metadata entry.
|
||||
* @param int $user_id ID of the user being updated.
|
||||
* @param string $meta_key Meta key being updated.
|
||||
|
@ -155,6 +163,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Schedule an action to anonymize a single Order.
|
||||
*
|
||||
* @internal
|
||||
* @param WC_Order $order Order object.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -168,6 +177,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Schedule an action to delete a single User.
|
||||
*
|
||||
* @internal
|
||||
* @param int $user_id User ID.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -181,6 +191,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Imports a single customer.
|
||||
*
|
||||
* @internal
|
||||
* @param int $user_id User ID.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -191,6 +202,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Delete a batch of customers.
|
||||
*
|
||||
* @internal
|
||||
* @param int $batch_size Number of items to delete.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -212,6 +224,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Anonymize the customer data for a single order.
|
||||
*
|
||||
* @internal
|
||||
* @param int $order_id Order id.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -264,6 +277,7 @@ class CustomersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Delete the customer data for a single user.
|
||||
*
|
||||
* @internal
|
||||
* @param int $user_id User ID.
|
||||
* @return void
|
||||
*/
|
|
@ -3,12 +3,13 @@
|
|||
* Import related abstract functions.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Schedulers;
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Schedulers;
|
||||
|
||||
interface ImportInterface {
|
||||
/**
|
||||
* Get items based on query and return IDs along with total available.
|
||||
*
|
||||
* @internal
|
||||
* @param int $limit Number of records to retrieve.
|
||||
* @param int $page Page number.
|
||||
* @param int|bool $days Number of days prior to current date to limit search results.
|
||||
|
@ -19,6 +20,7 @@ interface ImportInterface {
|
|||
/**
|
||||
* Get total number of items already imported.
|
||||
*
|
||||
* @internal
|
||||
* @return null
|
||||
*/
|
||||
public static function get_total_imported();
|
|
@ -3,7 +3,7 @@
|
|||
* Import related functions and actions.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Schedulers;
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Schedulers;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
|
@ -29,6 +29,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
/**
|
||||
* Returns true if an import is in progress.
|
||||
*
|
||||
* @internal
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_importing() {
|
||||
|
@ -58,6 +59,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
/**
|
||||
* Get batch sizes.
|
||||
*
|
||||
* @internal
|
||||
* @retun array
|
||||
*/
|
||||
public static function get_batch_sizes() {
|
||||
|
@ -76,6 +78,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
* Get all available scheduling actions.
|
||||
* Used to determine action hook names and clear events.
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public static function get_scheduler_actions() {
|
||||
|
@ -91,6 +94,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
/**
|
||||
* Queue the imports into multiple batches.
|
||||
*
|
||||
* @internal
|
||||
* @param integer|boolean $days Number of days to import.
|
||||
* @param boolean $skip_existing Skip exisiting records.
|
||||
*/
|
||||
|
@ -110,6 +114,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
/**
|
||||
* Imports a batch of items to update.
|
||||
*
|
||||
* @internal
|
||||
* @param int $batch_number Batch number to import (essentially a query page number).
|
||||
* @param int|bool $days Number of days to import.
|
||||
* @param bool $skip_existing Skip exisiting records.
|
||||
|
@ -146,6 +151,8 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
|
||||
/**
|
||||
* Queue item deletion in batches.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function delete_batch_init() {
|
||||
global $wpdb;
|
||||
|
@ -164,6 +171,7 @@ abstract class ImportScheduler implements ImportInterface {
|
|||
/**
|
||||
* Delete a batch by passing the count to be deleted to the child delete method.
|
||||
*
|
||||
* @internal
|
||||
* @return void
|
||||
*/
|
||||
public static function delete_batch() {
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Schedulers;
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Schedulers;
|
||||
|
||||
/**
|
||||
* Class MailchimpScheduler
|
||||
|
@ -26,6 +26,7 @@ class MailchimpScheduler {
|
|||
/**
|
||||
* MailchimpScheduler constructor.
|
||||
*
|
||||
* @internal
|
||||
* @param \WC_Logger_Interface|null $logger Logger instance.
|
||||
*/
|
||||
public function __construct( \WC_Logger_Interface $logger = null ) {
|
||||
|
@ -37,6 +38,8 @@ class MailchimpScheduler {
|
|||
|
||||
/**
|
||||
* Attempt to subscribe store_email to MailChimp.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function run() {
|
||||
// Abort if we've already subscribed to MailChimp.
|
||||
|
@ -82,6 +85,7 @@ class MailchimpScheduler {
|
|||
/**
|
||||
* Make an HTTP request to the API.
|
||||
*
|
||||
* @internal
|
||||
* @param string $store_email Email address to subscribe.
|
||||
*
|
||||
* @return mixed
|
|
@ -3,7 +3,7 @@
|
|||
* Order syncing related functions and actions.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Schedulers;
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Schedulers;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
|
@ -13,7 +13,6 @@ use \Automattic\WooCommerce\Admin\API\Reports\Products\DataStore as ProductsData
|
|||
use \Automattic\WooCommerce\Admin\API\Reports\Taxes\DataStore as TaxesDataStore;
|
||||
use \Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore as CustomersDataStore;
|
||||
use \Automattic\WooCommerce\Admin\API\Reports\Cache as ReportsCache;
|
||||
use \Automattic\WooCommerce\Admin\Schedulers\CustomersScheduler;
|
||||
|
||||
/**
|
||||
* OrdersScheduler Class.
|
||||
|
@ -28,6 +27,8 @@ class OrdersScheduler extends ImportScheduler {
|
|||
|
||||
/**
|
||||
* Attach order lookup update hooks.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function init() {
|
||||
// Activate WC_Order extension.
|
||||
|
@ -49,17 +50,19 @@ class OrdersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Add customer dependencies.
|
||||
*
|
||||
* @internal
|
||||
* @return array
|
||||
*/
|
||||
public static function get_dependencies() {
|
||||
return array(
|
||||
'import_batch_init' => CustomersScheduler::get_action( 'import_batch_init' ),
|
||||
'import_batch_init' => \Automattic\WooCommerce\Internal\Admin\Schedulers\CustomersScheduler::get_action( 'import_batch_init' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the order/refund IDs and total count that need to be synced.
|
||||
*
|
||||
* @internal
|
||||
* @param int $limit Number of records to retrieve.
|
||||
* @param int $page Page number.
|
||||
* @param int|bool $days Number of days prior to current date to limit search results.
|
||||
|
@ -111,6 +114,8 @@ class OrdersScheduler extends ImportScheduler {
|
|||
|
||||
/**
|
||||
* Get total number of rows imported.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function get_total_imported() {
|
||||
global $wpdb;
|
||||
|
@ -120,6 +125,7 @@ class OrdersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Schedule this import if the post is an order or refund.
|
||||
*
|
||||
* @internal
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
public static function possibly_schedule_import( $post_id ) {
|
||||
|
@ -134,6 +140,7 @@ class OrdersScheduler extends ImportScheduler {
|
|||
* Imports a single order or refund to update lookup tables for.
|
||||
* If an error is encountered in one of the updates, a retry action is scheduled.
|
||||
*
|
||||
* @internal
|
||||
* @param int $order_id Order or refund ID.
|
||||
* @return void
|
||||
*/
|
||||
|
@ -179,6 +186,7 @@ class OrdersScheduler extends ImportScheduler {
|
|||
/**
|
||||
* Delete a batch of orders.
|
||||
*
|
||||
* @internal
|
||||
* @param int $batch_size Number of items to delete.
|
||||
* @return void
|
||||
*/
|
|
@ -40,7 +40,7 @@ use \Automattic\WooCommerce\Admin\Notes\PerformanceOnMobile;
|
|||
use \Automattic\WooCommerce\Admin\Notes\ManageOrdersOnTheGo;
|
||||
use \Automattic\WooCommerce\Admin\Notes\AddFirstProduct;
|
||||
use \Automattic\WooCommerce\Admin\Notes\NavigationNudge;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\MailchimpScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
|
||||
use \Automattic\WooCommerce\Admin\Notes\CompleteStoreDetails;
|
||||
use \Automattic\WooCommerce\Admin\Notes\UpdateStoreDetails;
|
||||
use \Automattic\WooCommerce\Admin\Notes\SetUpAdditionalPaymentTypes;
|
||||
|
|
|
@ -11,7 +11,7 @@ use Automattic\WooCommerce\Admin\PageController;
|
|||
use Automattic\WooCommerce\Admin\WCAdminHelper;
|
||||
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Init as OnboardingTasks;
|
||||
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\MailchimpScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
|
||||
|
||||
/**
|
||||
* Contains backend logic for the onboarding profile and checklist feature.
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace Automattic\WooCommerce\Admin;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use Automattic\WooCommerce\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\OrdersScheduler;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\ImportScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\OrdersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\ImportScheduler;
|
||||
|
||||
/**
|
||||
* ReportsSync Class.
|
||||
|
@ -45,8 +45,8 @@ class ReportsSync {
|
|||
);
|
||||
|
||||
foreach ( $schedulers as $scheduler ) {
|
||||
if ( ! is_subclass_of( $scheduler, 'Automattic\WooCommerce\Admin\Schedulers\ImportScheduler' ) ) {
|
||||
throw new \Exception( __( 'Report sync schedulers should be derived from the Automattic\WooCommerce\Admin\Schedulers\ImportScheduler class.', 'woocommerce-admin' ) );
|
||||
if ( ! is_subclass_of( $scheduler, 'Automattic\WooCommerce\Internal\Admin\Schedulers\ImportScheduler' ) ) {
|
||||
throw new \Exception( __( 'Report sync schedulers should be derived from the Automattic\WooCommerce\Internal\Admin\Schedulers\ImportScheduler class.', 'woocommerce-admin' ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
use Automattic\WooCommerce\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\OrdersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\OrdersScheduler;
|
||||
use \Automattic\WooCommerce\Admin\API\Reports\Orders\Stats\DataStore as OrdersStatsDataStore;
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use \Automattic\WooCommerce\Admin\API\OnboardingProfile;
|
||||
use Automattic\WooCommerce\Admin\Features\Onboarding;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\MailchimpScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
|
||||
|
||||
/**
|
||||
* WC Tests API Onboarding Profile
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* @since 3.5.0
|
||||
*/
|
||||
|
||||
use Automattic\WooCommerce\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\OrdersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\CustomersScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\OrdersScheduler;
|
||||
|
||||
/**
|
||||
* Reports Generation Batch Queue Test Class
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
*/
|
||||
|
||||
use Automattic\WooCommerce\Admin\Features\Onboarding;
|
||||
use Automattic\WooCommerce\Admin\Schedulers\MailchimpScheduler;
|
||||
use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
|
||||
|
||||
/**
|
||||
* Class WC_Tests_Mailchimp_Scheduler
|
||||
*/
|
||||
class WC_Tests_Mailchimp_Scheduler extends WC_Unit_Test_Case {
|
||||
/**
|
||||
* @var MailchimpScheduler MailchimpScheduler instance to test
|
||||
* @var \Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler MailchimpScheduler instance to test
|
||||
*/
|
||||
private $instance;
|
||||
|
||||
|
|
Loading…
Reference in New Issue