Completed
Pull Request — master (#1523)
by
unknown
12:04
created

AliasesController::destroy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * @author Tahaa Karim <[email protected]>
4
 *
5
 * ownCloud - Mail
6
 *
7
 * This code is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License, version 3,
9
 * as published by the Free Software Foundation.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License, version 3,
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
18
 *
19
 */
20
21
namespace OCA\Mail\Controller;
22
23
use OCA\Mail\Db\Alias;
24
use OCP\IRequest;
25
use OCA\Mail\Service\AliasesService;
26
use OCP\AppFramework\Controller;
27
use OCP\AppFramework\Http\JSONResponse;
28
use OCP\AppFramework\Http;
29
30
class AliasesController extends Controller {
31
32
	/** @var AliasesService */
33
	private $aliasService;
34
35
	/**
36
	 * @var string
37
	 */
38
	private $currentUserId;
39
40
	/**
41
	 * @param string $appName
42
	 * @param IRequest $request
43
	 * @param AliasesService $aliasesService
44
	 */
45
	public function __construct($appName, IRequest $request, AliasesService $aliasesService) {
46
		parent::__construct($appName, $request);
47
		$this->aliasService = $aliasesService;
48
	}
49
50
	/**
51
	 * @NoAdminRequired
52
	 * @NoCSRFRequired
53
	 * @param int $accountId
54
	 * @return Alias[]
55
	 */
56
	public function index($accountId) {
57
		return $this->aliasService->findAll($accountId);
58
	}
59
60
	/**
61
	 * @NoAdminRequired
62
	 * @NoCSRFRequired
63
	 */
64
	public function show() {
65
		$response = new JSONResponse();
66
		$response->setStatus(Http::STATUS_NOT_IMPLEMENTED);
67
		return $response;
68
	}
69
70
	/**
71
	 * @NoAdminRequired
72
	 * @NoCSRFRequired
73
	 * @param int $id
74
	 * @param string $alias
75
	 * @return Alias[]
76
	 */
77
	public function update($id, $alias) {
78
		return $this->aliasService->update($id, $alias);
79
	}
80
81
	/**
82
	 * @NoAdminRequired
83
	 * @NoCSRFRequired
84
	 * @param int $id
85
	 * @return Alias[]
86
	 */
87
	public function destroy($id) {
88
		return $this->aliasService->delete($id);
89
	}
90
91
	/**
92
	 * @NoAdminRequired
93
	 * @NoCSRFRequired
94
	 * @param int $accountId
95
	 * @param string $alias
96
	 * @return Alias[]
97
	 */
98
	public function create($accountId, $alias) {
99
		return $this->aliasService->create($accountId, $alias);
100
	}
101
}
102