Completed
Pull Request — master (#40)
by Janis
123:40 queued 121:18
created

PersonalSettingsController::deleteStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * nextCloud - ocr
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Janis Koehr <[email protected]>
9
 * @copyright Janis Koehr 2017
10
 */
11
12
namespace OCA\Ocr\Controller;
13
14
use OCA\Ocr\Db\OcrStatusMapper;
15
use OCA\Ocr\Service\OcrService;
16
use OCP\AppFramework\Controller;
17
use OCP\AppFramework\Http\TemplateResponse;
18
use OCP\IRequest;
19
use OCP\Template;
20
21
class PersonalSettingsController extends Controller {
22
23
	/**
24
	 * @var string
25
	 */
26
	private $userId;
27
28
	/**
29
	 * @var OcrService
30
	 */
31
	private $service;
32
33
	use Errors;
34
35
	/**
36
	 * PersonalSettingsController constructor.
37
	 *
38
	 * @param string $AppName
39
	 * @param IRequest $request
40
	 * @param OcrService $service
41
	 * @param $UserId
42
	 */
43 6
	public function __construct($AppName, IRequest $request, OcrService $service, $UserId) {
44 6
		parent::__construct($AppName, $request);
45 6
		$this->userId = $UserId;
46 6
		$this->service = $service;
47 6
	}
48
49
    /**
50
     * @NoAdminRequired
51
     *
52
     * @return Template
53
     */
54 1
	public function displayPanel() {
55 1
		$tmpl = new Template('ocr', 'settings-personal');
56 1
		return $tmpl;
57
	}
58
59
	/**
60
	 * @NoAdminRequired
61
	 *
62
	 * @return \OCP\AppFramework\Http\DataResponse
63
	 */
64 2
	public function getAll() {
65
		return $this->handleNotFound(function () {
66 2
            return $this->service->getAllForPersonal($this->userId);
67 2
		});
68
	}
69
70
	/**
71
	 * @NoAdminRequired
72
	 *
73
	 * @return \OCP\AppFramework\Http\DataResponse
74
	 */
75
	public function deleteStatus($id) {
76 2
		return $this->handleNotFound(function () use ($id) {
77 2
			return $this->service->deleteStatus($id, $this->userId);
78 2
		});
79
	}
80
}