Completed
Push — master ( f94cea...cfc523 )
by Morris
12s
created

Application::__construct()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 20
cp 0
rs 9.2
c 0
b 0
f 0
cc 2
eloc 16
nc 1
nop 1
crap 6
1
<?php
2
/**
3
 * @author Björn Schießle <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2015, ownCloud, Inc.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
23
namespace OCA\FilesTextEditor\AppInfo;
24
25
use OCA\FilesTextEditor\Controller\FileHandlingController;
26
use OCP\AppFramework\App;
27
use OCP\AppFramework\IAppContainer;
28
29
class Application extends App {
30
31
	/**
32
	 * @param array $urlParams
33
	 */
34
	public function __construct(array $urlParams = array()) {
35
		parent::__construct('files_texteditor', $urlParams);
36
37
		$container = $this->getContainer();
38
		$server = $container->getServer();
39
40
		$container->registerService('FileHandlingController', function (IAppContainer $c) use ($server) {
41
			$user = $server->getUserSession()->getUser();
42
			if ($user) {
43
				$uid = $user->getUID();
44
			} else {
45
				throw new \BadMethodCallException('no user logged in');
46
			}
47
			return new FileHandlingController(
48
				$c->getAppName(),
49
				$server->getRequest(),
50
				$server->getL10N($c->getAppName()),
51
				$server->getLogger(),
52
				$server->getUserFolder($uid)
53
			);
54
		});
55
	}
56
}
57