44 lines
863 B
PHP
44 lines
863 B
PHP
<?php
|
|
|
|
namespace MailPoet\Router\Endpoints;
|
|
|
|
use MailPoet\Config\AccessControl;
|
|
use MailPoet\Cron\CronHelper;
|
|
use MailPoet\Cron\DaemonHttpRunner;
|
|
|
|
if(!defined('ABSPATH')) exit;
|
|
|
|
class CronDaemon {
|
|
const ENDPOINT = 'cron_daemon';
|
|
const ACTION_RUN = 'run';
|
|
const ACTION_PING = 'ping';
|
|
const ACTION_PING_RESPONSE = 'pingResponse';
|
|
public $allowed_actions = array(
|
|
self::ACTION_RUN,
|
|
self::ACTION_PING,
|
|
self::ACTION_PING_RESPONSE
|
|
);
|
|
public $data;
|
|
public $permissions = array(
|
|
'global' => AccessControl::NO_ACCESS_RESTRICTION
|
|
);
|
|
|
|
function __construct($data) {
|
|
$this->data = $data;
|
|
}
|
|
|
|
function run() {
|
|
$queue = new DaemonHttpRunner($this->data);
|
|
$queue->run();
|
|
}
|
|
|
|
function ping() {
|
|
die(CronHelper::pingDaemon());
|
|
}
|
|
|
|
function pingResponse() {
|
|
$queue = new DaemonHttpRunner();
|
|
$queue->ping();
|
|
}
|
|
}
|