Captcha.php
4 months ago
CronDaemon.php
3 years ago
ExportDownload.php
2 months ago
FormPreview.php
2 years ago
Subscription.php
5 days ago
TemplateImage.php
2 months ago
Track.php
2 months ago
ViewInBrowser.php
1 month ago
index.php
3 years ago
CronDaemon.php
53 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Router\Endpoints; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Config\AccessControl; |
| 9 | use MailPoet\Cron\CronHelper; |
| 10 | use MailPoet\Cron\DaemonHttpRunner; |
| 11 | |
| 12 | class CronDaemon { |
| 13 | const ENDPOINT = 'cron_daemon'; |
| 14 | const ACTION_RUN = 'run'; |
| 15 | const ACTION_PING = 'ping'; |
| 16 | const ACTION_PING_RESPONSE = 'pingResponse'; |
| 17 | public $allowedActions = [ |
| 18 | self::ACTION_RUN, |
| 19 | self::ACTION_PING, |
| 20 | self::ACTION_PING_RESPONSE, |
| 21 | ]; |
| 22 | public $data; |
| 23 | public $permissions = [ |
| 24 | 'global' => AccessControl::NO_ACCESS_RESTRICTION, |
| 25 | ]; |
| 26 | |
| 27 | /** @var DaemonHttpRunner */ |
| 28 | private $daemonRunner; |
| 29 | |
| 30 | /** @var CronHelper */ |
| 31 | private $cronHelper; |
| 32 | |
| 33 | public function __construct( |
| 34 | DaemonHttpRunner $daemonRunner, |
| 35 | CronHelper $cronHelper |
| 36 | ) { |
| 37 | $this->daemonRunner = $daemonRunner; |
| 38 | $this->cronHelper = $cronHelper; |
| 39 | } |
| 40 | |
| 41 | public function run($data) { |
| 42 | $this->daemonRunner->run($data); |
| 43 | } |
| 44 | |
| 45 | public function ping() { |
| 46 | die(esc_html($this->cronHelper->pingDaemon())); |
| 47 | } |
| 48 | |
| 49 | public function pingResponse() { |
| 50 | $this->daemonRunner->ping(); |
| 51 | } |
| 52 | } |
| 53 |