Files
piratepoet/lib/Cron/Workers/KeyCheck/KeyCheckWorker.php
Ján Mikláš 3ee58aea10 Add space between if and ‘(‘
[MAILPOET-1791]
2019-02-13 08:26:27 -05:00

39 lines
844 B
PHP

<?php
namespace MailPoet\Cron\Workers\KeyCheck;
use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Workers\SimpleWorker;
use MailPoet\Models\ScheduledTask;
use MailPoet\Services\Bridge;
if (!defined('ABSPATH')) exit;
abstract class KeyCheckWorker extends SimpleWorker {
const UNAVAILABLE_SERVICE_RESCHEDULE_TIMEOUT = 60;
public $bridge;
function init() {
if (!$this->bridge) {
$this->bridge = new Bridge();
}
}
function processTaskStrategy(ScheduledTask $task) {
try {
$result = $this->checkKey();
} catch (\Exception $e) {
$result = false;
}
if (empty($result['code']) || $result['code'] == Bridge::CHECK_ERROR_UNAVAILABLE) {
$this->reschedule($task, self::UNAVAILABLE_SERVICE_RESCHEDULE_TIMEOUT);
return false;
}
return true;
}
abstract function checkKey();
}