Refactor WPFunctions to be injectable with DI

This commit is contained in:
Amine Ben hammou
2018-12-12 14:41:44 +01:00
parent e059ee7364
commit a46d98ec44
23 changed files with 146 additions and 97 deletions

View File

@@ -19,6 +19,7 @@ if(!defined('ABSPATH')) exit;
class Scheduler {
public $timer;
private $wp;
const UNCONFIRMED_SUBSCRIBER_RESCHEDULE_TIMEOUT = 5;
const TASK_BATCH_SIZE = 5;
@@ -26,6 +27,7 @@ class Scheduler {
$this->timer = ($timer) ? $timer : microtime(true);
// abort if execution limit is reached
CronHelper::enforceExecutionLimit($this->timer);
$this->wp = new WPFunctions();
}
function process() {
@@ -172,7 +174,7 @@ class Scheduler {
// check if subscriber is confirmed (subscribed)
if($subscriber->status !== Subscriber::STATUS_SUBSCRIBED) {
// reschedule delivery in 5 minutes
$scheduled_at = Carbon::createFromTimestamp(WPFunctions::currentTime('timestamp'));
$scheduled_at = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
$queue->scheduled_at = $scheduled_at->addMinutes(
self::UNCONFIRMED_SUBSCRIBER_RESCHEDULE_TIMEOUT
);