- Adds new "ping" cron daemon router endpoint

- Removes the requirement to have data payload for router requests
This commit is contained in:
Vlad
2017-01-08 20:46:24 -05:00
parent aa0078e5e4
commit a6b00e1ba7
7 changed files with 88 additions and 37 deletions

View File

@ -0,0 +1,38 @@
<?php
namespace MailPoet\Router\Endpoints;
use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Daemon;
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;
function __construct($data) {
$this->data = $data;
}
function run() {
$queue = new Daemon($this->data);
$queue->run();
}
function ping() {
die(CronHelper::pingDaemon());
}
function pingResponse() {
$queue = new Daemon();
$queue->ping();
}
}