Application::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *  
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *  
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *  
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *  
22
 */
23
24
namespace OCA\Deck\AppInfo;
25
26
use OCP\AppFramework\App;
27
use OCA\Deck\Middleware\SharingMiddleware;
28
29
30
class Application extends App {
31
32
	/**
33
	 * Application constructor.
34
	 *
35
	 * @param array $urlParams
36
	 */
37
	public function __construct(array $urlParams = array()) {
38
		parent::__construct('deck', $urlParams);
39
40
		$container = $this->getContainer();
41
		$server = $container->getServer();
42
43
		$container->registerService('SharingMiddleware', function($container) use ($server) {
44
			return new SharingMiddleware(
45
				$container,
46
				$server->getRequest(),
47
				$server->getUserSession(),
48
				$container->query('ControllerMethodReflector'),
49
				$container->query('OCA\Deck\Service\PermissionService')
50
			);
51
		});
52
		$container->registerMiddleware('SharingMiddleware');
53
54
	}
55
56
	public function registerNavigationEntry() {
57
		$container = $this->getContainer();
58
		$container->query('OCP\INavigationManager')->add(function() use ($container) {
59
			$urlGenerator = $container->query('OCP\IURLGenerator');
60
			$l10n = $container->query('OCP\IL10N');
61
			return [
62
				'id' => 'deck',
63
				'order' => 10,
64
				'href' => $urlGenerator->linkToRoute('deck.page.index'),
65
				'icon' => $urlGenerator->imagePath('deck', 'app.svg'),
66
				'name' => $l10n->t('Deck'),
67
			];
68
		});
69
	}
70
}
71