tasks/lib/Controller/SettingsController.php

66 lines
1.7 KiB
PHP
Raw Normal View History

2014-05-27 17:59:35 +00:00
<?php
/**
* Nextcloud - Tasks
2015-07-19 12:05:29 +00:00
*
* @author Raimund Schlüßler
2018-08-19 20:33:26 +00:00
* @copyright 2018 Raimund Schlüßler <raimund.schluessler@mailbox.org>
2015-07-19 12:05:29 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
2014-05-27 17:59:35 +00:00
2014-07-30 19:03:54 +00:00
namespace OCA\Tasks\Controller;
2014-05-27 17:59:35 +00:00
2015-06-23 10:08:52 +00:00
use \OCA\Tasks\Service\SettingsService;
2014-08-17 20:35:34 +00:00
use \OCP\AppFramework\Controller;
2016-03-08 21:23:27 +00:00
use \OCP\IRequest;
2014-05-27 17:59:35 +00:00
class SettingsController extends Controller {
2019-01-26 20:47:53 +00:00
/**
* @var SettingsService
*/
2015-06-23 10:08:52 +00:00
private $settingsService;
2014-08-17 20:35:34 +00:00
use Response;
2019-01-26 20:47:53 +00:00
/**
* @param string $appName
* @param IRequest $request an instance of the request
* @param SettingsService $settingsService
*/
public function __construct(string $appName, IRequest $request, SettingsService $settingsService){
2014-08-17 20:35:34 +00:00
parent::__construct($appName, $request);
2015-06-23 10:08:52 +00:00
$this->settingsService = $settingsService;
2014-08-17 20:35:34 +00:00
}
2014-05-27 17:59:35 +00:00
/**
* @NoAdminRequired
*/
2014-08-17 20:35:34 +00:00
public function get(){
return $this->generateResponse(function () {
return ['settings' => $this->settingsService->get()];
});
2014-05-27 17:59:35 +00:00
}
/**
* @NoAdminRequired
*/
2019-01-26 20:47:53 +00:00
public function set($setting, $value) {
2018-09-02 13:44:29 +00:00
return $this->generateResponse(function () use ($setting, $value) {
return $this->settingsService->set($setting, $value);
});
2014-05-27 17:59:35 +00:00
}
2015-07-19 12:05:29 +00:00
}