-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathAbstractProductSyncerBatchedJob.php
86 lines (75 loc) · 2.56 KB
/
AbstractProductSyncerBatchedJob.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Jobs;
use Automattic\WooCommerce\GoogleListingsAndAds\ActionScheduler\ActionSchedulerInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\API\WP\NotificationsService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantCenterService;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\MerchantStatuses;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\BatchProductHelper;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductRepository;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\ProductSyncer;
defined( 'ABSPATH' ) || exit;
/**
* Class AbstractGoogleBatchedJob
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Jobs
*/
abstract class AbstractProductSyncerBatchedJob extends AbstractBatchedActionSchedulerJob {
/**
* @var ProductSyncer
*/
protected $product_syncer;
/**
* @var ProductRepository
*/
protected $product_repository;
/**
* @var BatchProductHelper
*/
protected $batch_product_helper;
/**
* @var MerchantCenterService
*/
protected $merchant_center;
/**
* @var MerchantStatuses
*/
protected $merchant_statuses;
/**
* AbstractProductSyncerBatchedJob constructor.
*
* @param ActionSchedulerInterface $action_scheduler
* @param ActionSchedulerJobMonitor $monitor
* @param ProductSyncer $product_syncer
* @param ProductRepository $product_repository
* @param BatchProductHelper $batch_product_helper
* @param MerchantCenterService $merchant_center
* @param MerchantStatuses $merchant_statuses
*/
public function __construct(
ActionSchedulerInterface $action_scheduler,
ActionSchedulerJobMonitor $monitor,
ProductSyncer $product_syncer,
ProductRepository $product_repository,
BatchProductHelper $batch_product_helper,
MerchantCenterService $merchant_center,
MerchantStatuses $merchant_statuses
) {
$this->batch_product_helper = $batch_product_helper;
$this->product_syncer = $product_syncer;
$this->product_repository = $product_repository;
$this->merchant_center = $merchant_center;
$this->merchant_statuses = $merchant_statuses;
parent::__construct( $action_scheduler, $monitor );
}
/**
* Can the job be scheduled.
*
* @param array|null $args
*
* @return bool Returns true if the job can be scheduled.
*/
public function can_schedule( $args = [] ): bool {
return ! $this->is_running( $args ) && $this->merchant_center->is_enabled_for_datatype( NotificationsService::DATATYPE_PRODUCT );
}
}