Completed
Pull Request — master (#1523)
by
unknown
08:37
created

AliasesController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 6
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 72
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 3 1
A show() 0 5 1
A update() 0 3 1
A destroy() 0 3 1
A create() 0 3 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