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

@ -16,6 +16,13 @@ class ScheduledTask extends Model {
const PRIORITY_MEDIUM = 5;
const PRIORITY_LOW = 10;
private $wp;
function __construct() {
parent::__construct();
$this->wp = new WPFunctions();
}
function subscribers() {
return $this->hasManyThrough(
__NAMESPACE__.'\Subscriber',
@ -61,7 +68,7 @@ class ScheduledTask extends Model {
}
function complete() {
$this->processed_at = WPFunctions::currentTime('mysql');
$this->processed_at = $this->wp->currentTime('mysql');
$this->set('status', self::STATUS_COMPLETED);
$this->save();
return ($this->getErrors() === false && $this->id() > 0);