Use CronHelper service in API and UI classes [MAILPOET-2459]

This commit is contained in:
wxa
2019-10-30 16:27:47 +03:00
committed by Jack Kitterhing
parent 81caa04479
commit 31d224ea4f
5 changed files with 37 additions and 11 deletions

View File

@ -47,6 +47,9 @@ class Newsletters extends APIEndpoint {
/** @var SettingsController */
private $settings;
/** @var CronHelper */
private $cron_helper;
/** @var AuthorizedEmailsController */
private $authorized_emails_controller;
@ -75,6 +78,7 @@ class Newsletters extends APIEndpoint {
WPFunctions $wp,
WCHelper $woocommerce_helper,
SettingsController $settings,
CronHelper $cron_helper,
AuthorizedEmailsController $authorized_emails_controller,
NewslettersRepository $newsletters_repository,
NewslettersResponseBuilder $newsletters_response_builder,
@ -87,6 +91,7 @@ class Newsletters extends APIEndpoint {
$this->wp = $wp;
$this->woocommerce_helper = $woocommerce_helper;
$this->settings = $settings;
$this->cron_helper = $cron_helper;
$this->authorized_emails_controller = $authorized_emails_controller;
$this->newsletters_repository = $newsletters_repository;
$this->newsletters_response_builder = $newsletters_response_builder;
@ -556,7 +561,7 @@ class Newsletters extends APIEndpoint {
'groups' => $listing_data['groups'],
'mta_log' => $this->settings->get('mta_log'),
'mta_method' => $this->settings->get('mta.method'),
'cron_accessible' => CronHelper::isDaemonAccessible(),
'cron_accessible' => $this->cron_helper->isDaemonAccessible(),
'current_time' => $this->wp->currentTime('mysql'),
]);
}

View File

@ -25,16 +25,21 @@ class SendingTaskSubscribers extends APIEndpoint {
/** @var SettingsController */
private $settings;
/** @var CronHelper */
private $cron_helper;
/** @var WPFunctions */
private $wp;
function __construct(
Listing\Handler $listing_handler,
SettingsController $settings,
CronHelper $cron_helper,
WPFunctions $wp
) {
$this->listing_handler = $listing_handler;
$this->settings = $settings;
$this->cron_helper = $cron_helper;
$this->wp = $wp;
}
@ -62,7 +67,7 @@ class SendingTaskSubscribers extends APIEndpoint {
'groups' => $listing_data['groups'],
'mta_log' => $this->settings->get('mta_log'),
'mta_method' => $this->settings->get('mta.method'),
'cron_accessible' => CronHelper::isDaemonAccessible(),
'cron_accessible' => $this->cron_helper->isDaemonAccessible(),
'current_time' => $this->wp->currentTime('mysql'),
]);
}