Files
piratepoet/lib/Cron/Workers/WooCommerceSync.php
Rodrigo Primo 963da3bf16 Refactor the method processTaskStrategy() of some SimpleWorker child classes
This commit refactors the method processTaskStrategy() of some
SimpleWorker child classes to use Doctrine instead of Paris. In this
commit are included all the classes that it was only necessary to change
the method signature as they were receiving a ScheduledTask object as
the first parameter but didn't use it. Now they receive a
ScheduledTaskEntity object as the first param.

[MAILPOET-3843]
2021-10-05 13:21:53 +02:00

38 lines
1018 B
PHP

<?php
namespace MailPoet\Cron\Workers;
use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Segments\WooCommerce as WooCommerceSegment;
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
class WooCommerceSync extends SimpleWorker {
const TASK_TYPE = 'woocommerce_sync';
const SUPPORT_MULTIPLE_INSTANCES = false;
const AUTOMATIC_SCHEDULING = false;
/** @var WooCommerceSegment */
private $woocommerceSegment;
/** @var WooCommerceHelper */
private $woocommerceHelper;
public function __construct(
WooCommerceSegment $woocommerceSegment,
WooCommerceHelper $woocommerceHelper
) {
$this->woocommerceSegment = $woocommerceSegment;
$this->woocommerceHelper = $woocommerceHelper;
parent::__construct();
}
public function checkProcessingRequirements() {
return $this->woocommerceHelper->isWooCommerceActive();
}
public function processTaskStrategy(ScheduledTaskEntity $task, $timer) {
$this->woocommerceSegment->synchronizeCustomers();
return true;
}
}