Simplify CronTrigger methods list & its usage
[MAILPOET-2538]
This commit is contained in:
committed by
Jack Kitterhing
parent
69b79b4f6c
commit
b1aed487be
@ -76,7 +76,7 @@ class Settings {
|
|||||||
$data = [
|
$data = [
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
'segments' => Segment::getSegmentsWithSubscriberCount(),
|
||||||
'cron_trigger' => CronTrigger::getAvailableMethods(),
|
'cron_trigger' => CronTrigger::METHODS,
|
||||||
'total_subscribers' => Subscriber::getTotalSubscribers(),
|
'total_subscribers' => Subscriber::getTotalSubscribers(),
|
||||||
'premium_plugin_active' => License::getLicense(),
|
'premium_plugin_active' => License::getLicense(),
|
||||||
'premium_key_valid' => !empty($premium_key_valid),
|
'premium_key_valid' => !empty($premium_key_valid),
|
||||||
|
@ -30,7 +30,7 @@ class Reporter {
|
|||||||
global $wpdb, $wp_version, $woocommerce;
|
global $wpdb, $wp_version, $woocommerce;
|
||||||
$mta = $this->settings->get('mta', []);
|
$mta = $this->settings->get('mta', []);
|
||||||
$newsletters = Newsletter::getAnalytics();
|
$newsletters = Newsletter::getAnalytics();
|
||||||
$isCronTriggerMethodWP = $this->settings->get('cron_trigger.method') === CronTrigger::$available_methods['wordpress'];
|
$isCronTriggerMethodWP = $this->settings->get('cron_trigger.method') === CronTrigger::METHOD_WORDPRESS;
|
||||||
$checker = new ServicesChecker();
|
$checker = new ServicesChecker();
|
||||||
$bounceAddress = $this->settings->get('bounce.address');
|
$bounceAddress = $this->settings->get('bounce.address');
|
||||||
$segments = Segment::getAnalytics();
|
$segments = Segment::getAnalytics();
|
||||||
|
@ -12,12 +12,13 @@ class CronTrigger {
|
|||||||
const METHOD_MAILPOET = 'MailPoet';
|
const METHOD_MAILPOET = 'MailPoet';
|
||||||
const METHOD_WORDPRESS = 'WordPress';
|
const METHOD_WORDPRESS = 'WordPress';
|
||||||
|
|
||||||
public static $available_methods = [
|
const METHODS = [
|
||||||
'mailpoet' => self::METHOD_MAILPOET,
|
'mailpoet' => self::METHOD_MAILPOET,
|
||||||
'wordpress' => self::METHOD_WORDPRESS,
|
'wordpress' => self::METHOD_WORDPRESS,
|
||||||
'linux_cron' => self::METHOD_LINUX_CRON,
|
'linux_cron' => self::METHOD_LINUX_CRON,
|
||||||
'none' => 'Disabled',
|
'none' => 'Disabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFAULT_METHOD = 'WordPress';
|
const DEFAULT_METHOD = 'WordPress';
|
||||||
const SETTING_NAME = 'cron_trigger';
|
const SETTING_NAME = 'cron_trigger';
|
||||||
|
|
||||||
@ -36,8 +37,4 @@ class CronTrigger {
|
|||||||
// cron exceptions should not prevent the rest of the site from loading
|
// cron exceptions should not prevent the rest of the site from loading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAvailableMethods() {
|
|
||||||
return self::$available_methods;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,7 @@ class DaemonHttpRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isCronTriggerMethodWordPress() {
|
function isCronTriggerMethodWordPress() {
|
||||||
$available_methods = CronTrigger::getAvailableMethods();
|
return $this->settings->get(CronTrigger::SETTING_NAME . '.method') === CronTrigger::METHOD_WORDPRESS;
|
||||||
return $this->settings->get(CronTrigger::SETTING_NAME . '.method') === $available_methods['wordpress'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkWPTriggerExecutionRequirements() {
|
function checkWPTriggerExecutionRequirements() {
|
||||||
|
@ -34,11 +34,6 @@ class CronTriggerTest extends \MailPoetTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItCanReturnAvailableMethods() {
|
|
||||||
expect($this->cron_trigger->getAvailableMethods())
|
|
||||||
->equals(CronTrigger::$available_methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testItCanInitializeCronTriggerMethod() {
|
function testItCanInitializeCronTriggerMethod() {
|
||||||
$settings_mock = Stub::makeEmpty(
|
$settings_mock = Stub::makeEmpty(
|
||||||
SettingsController::class,
|
SettingsController::class,
|
||||||
|
Reference in New Issue
Block a user