Refactor MailPoet\API to use new settings
[MAILPOET-1757]
This commit is contained in:
@@ -7,16 +7,25 @@ use MailPoet\API\JSON\Error as APIError;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Settings extends APIEndpoint {
|
||||
|
||||
/** @var SettingsController */
|
||||
private $settings;
|
||||
|
||||
public $permissions = array(
|
||||
'global' => AccessControl::PERMISSION_MANAGE_SETTINGS
|
||||
);
|
||||
|
||||
function __construct(SettingsController $settings) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
function get() {
|
||||
return $this->successResponse(Setting::getAll());
|
||||
return $this->successResponse($this->settings->getAll());
|
||||
}
|
||||
|
||||
function set($settings = array()) {
|
||||
@@ -28,11 +37,11 @@ class Settings extends APIEndpoint {
|
||||
));
|
||||
} else {
|
||||
foreach($settings as $name => $value) {
|
||||
Setting::setValue($name, $value);
|
||||
$this->settings->set($name, $value);
|
||||
}
|
||||
$bridge = new Bridge();
|
||||
$bridge->onSettingsSave($settings);
|
||||
return $this->successResponse(Setting::getAll());
|
||||
return $this->successResponse($this->settings->getAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user