Convert variable names to camel case
[MAILPOET-1796]
This commit is contained in:
@ -38,13 +38,13 @@ class Settings extends APIEndpoint {
|
||||
public function __construct(
|
||||
SettingsController $settings,
|
||||
Bridge $bridge,
|
||||
AuthorizedEmailsController $authorized_emails_controller,
|
||||
TransactionalEmails $wc_transactional_emails
|
||||
AuthorizedEmailsController $authorizedEmailsController,
|
||||
TransactionalEmails $wcTransactionalEmails
|
||||
) {
|
||||
$this->settings = $settings;
|
||||
$this->bridge = $bridge;
|
||||
$this->authorized_emails_controller = $authorized_emails_controller;
|
||||
$this->wc_transactional_emails = $wc_transactional_emails;
|
||||
$this->authorizedEmailsController = $authorizedEmailsController;
|
||||
$this->wcTransactionalEmails = $wcTransactionalEmails;
|
||||
}
|
||||
|
||||
public function get() {
|
||||
@ -59,44 +59,44 @@ class Settings extends APIEndpoint {
|
||||
WPFunctions::get()->__('You have not specified any settings to be saved.', 'mailpoet'),
|
||||
]);
|
||||
} else {
|
||||
$old_settings = $this->settings->getAll();
|
||||
$signup_confirmation = $this->settings->get('signup_confirmation.enabled');
|
||||
$oldSettings = $this->settings->getAll();
|
||||
$signupConfirmation = $this->settings->get('signup_confirmation.enabled');
|
||||
foreach ($settings as $name => $value) {
|
||||
$this->settings->set($name, $value);
|
||||
}
|
||||
|
||||
$this->onSettingsChange($old_settings, $this->settings->getAll());
|
||||
$this->onSettingsChange($oldSettings, $this->settings->getAll());
|
||||
|
||||
$this->bridge->onSettingsSave($settings);
|
||||
$this->authorized_emails_controller->onSettingsSave($settings);
|
||||
if ($signup_confirmation !== $this->settings->get('signup_confirmation.enabled')) {
|
||||
$this->authorizedEmailsController->onSettingsSave($settings);
|
||||
if ($signupConfirmation !== $this->settings->get('signup_confirmation.enabled')) {
|
||||
Form::updateSuccessMessages();
|
||||
}
|
||||
return $this->successResponse($this->settings->getAll());
|
||||
}
|
||||
}
|
||||
|
||||
private function onSettingsChange($old_settings, $new_settings) {
|
||||
private function onSettingsChange($oldSettings, $newSettings) {
|
||||
// Recalculate inactive subscribers
|
||||
$old_inactivation_interval = $old_settings['deactivate_subscriber_after_inactive_days'];
|
||||
$new_inactivation_interval = $new_settings['deactivate_subscriber_after_inactive_days'];
|
||||
if ($old_inactivation_interval !== $new_inactivation_interval) {
|
||||
$oldInactivationInterval = $oldSettings['deactivate_subscriber_after_inactive_days'];
|
||||
$newInactivationInterval = $newSettings['deactivate_subscriber_after_inactive_days'];
|
||||
if ($oldInactivationInterval !== $newInactivationInterval) {
|
||||
$this->onInactiveSubscribersIntervalChange();
|
||||
}
|
||||
|
||||
// Sync WooCommerce Customers list
|
||||
$old_subscribe_old_woocommerce_customers = isset($old_settings['mailpoet_subscribe_old_woocommerce_customers']['enabled'])
|
||||
? $old_settings['mailpoet_subscribe_old_woocommerce_customers']['enabled']
|
||||
$oldSubscribeOldWoocommerceCustomers = isset($oldSettings['mailpoet_subscribe_old_woocommerce_customers']['enabled'])
|
||||
? $oldSettings['mailpoet_subscribe_old_woocommerce_customers']['enabled']
|
||||
: '0';
|
||||
$new_subscribe_old_woocommerce_customers = isset($new_settings['mailpoet_subscribe_old_woocommerce_customers']['enabled'])
|
||||
? $new_settings['mailpoet_subscribe_old_woocommerce_customers']['enabled']
|
||||
$newSubscribeOldWoocommerceCustomers = isset($newSettings['mailpoet_subscribe_old_woocommerce_customers']['enabled'])
|
||||
? $newSettings['mailpoet_subscribe_old_woocommerce_customers']['enabled']
|
||||
: '0';
|
||||
if ($old_subscribe_old_woocommerce_customers !== $new_subscribe_old_woocommerce_customers) {
|
||||
if ($oldSubscribeOldWoocommerceCustomers !== $newSubscribeOldWoocommerceCustomers) {
|
||||
$this->onSubscribeOldWoocommerceCustomersChange();
|
||||
}
|
||||
|
||||
if (!empty($new_settings['woocommerce']['use_mailpoet_editor'])) {
|
||||
$this->wc_transactional_emails->init();
|
||||
if (!empty($newSettings['woocommerce']['use_mailpoet_editor'])) {
|
||||
$this->wcTransactionalEmails->init();
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ class Settings extends APIEndpoint {
|
||||
$task->status = ScheduledTask::STATUS_SCHEDULED;
|
||||
}
|
||||
$datetime = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
|
||||
$task->scheduled_at = $datetime->subMinute();
|
||||
$task->scheduledAt = $datetime->subMinute();
|
||||
$task->save();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class Settings extends APIEndpoint {
|
||||
$task->status = ScheduledTask::STATUS_SCHEDULED;
|
||||
}
|
||||
$datetime = Carbon::createFromTimestamp((int)WPFunctions::get()->currentTime('timestamp'));
|
||||
$task->scheduled_at = $datetime->subMinute();
|
||||
$task->scheduledAt = $datetime->subMinute();
|
||||
$task->save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user