Completed
Pull Request — master (#207)
by korelstar
41:14
created

SettingsController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
namespace OCA\Notes\Controller;
3
use OCP\AppFramework\Controller;
4
5
use OCP\IConfig;
6
use OCP\IRequest;
7
use OCP\IUserManager;
8
use OCP\IUserSession;
9
use OCP\Files\IRootFolder;
10
use OCP\AppFramework\Http\JSONResponse;
11
use OCA\Notes\Service\SettingsService;
12
13
class SettingsController extends Controller
14
{
15
	private $service;
16
17
	public function __construct(
18
		$appName,
19
		IRequest $request,
20
		SettingsService $service
21
	) {
22
		parent::__construct($appName, $request);
23
		$this->service = $service;
24
	}
25
26
	/**
27
	 * @NoAdminRequired
28
	 * @throws \OCP\PreConditionNotMetException
29
	 */
30
	public function set() {
31
		$this->service->set($this->request->getParams());
32
		return $this->get();
33
	}
34
35
	/**
36
	 * @NoAdminRequired
37
	 */
38
	public function get() {
39
		return new JSONResponse($this->service->get());
40
	}
41
}
42