Application   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 67
ccs 0
cts 42
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 63 3
1
<?php
2
3
/**
4
 * ownCloud - bookmarks
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 * @author Marvin Thomas Rabe <[email protected]>
9
 * @author Arthur Schiwon <[email protected]>
10
 * @author Stefan Klemm <[email protected]>
11
 * @copyright (c) 2011, Marvin Thomas Rabe
12
 * @copyright (c) 2011, Arthur Schiwon
13
 * @copyright (c) 2014, Stefan Klemm
14
 */
15
16
namespace OCA\Bookmarks\AppInfo;
17
18
use \OCP\AppFramework\App;
19
use \OCP\IContainer;
20
use \OCA\Bookmarks\Controller\WebViewController;
21
use OCA\Bookmarks\Controller\Rest\TagsController;
22
use OCA\Bookmarks\Controller\Rest\BookmarkController;
23
use OCA\Bookmarks\Controller\Rest\PublicController;
24
use OCP\IUser;
25
26
class Application extends App {
27
28
	public function __construct(array $urlParams = array()) {
29
		parent::__construct('bookmarks', $urlParams);
30
31
		$container = $this->getContainer();
32
33
		/**
34
		 * Controllers
35
		 * @param IContainer $c The Container instance that handles the request
36
		 */
37
		$container->registerService('WebViewController', function($c) {
38
			/** @var IUser|null $user */
39
			$user = $c->query('ServerContainer')->getUserSession()->getUser();
40
			$uid = is_null($user) ? null : $user->getUID();
41
42
			/** @var IContainer $c */
43
			return new WebViewController(
44
				$c->query('AppName'),
45
				$c->query('Request'),
46
				$uid,
47
				$c->query('ServerContainer')->getURLGenerator(),
48
				$c->query('ServerContainer')->getDb()
49
			);
50
		});
51
52
		$container->registerService('BookmarkController', function($c) {
53
			if(method_exists($c->query('ServerContainer'), 'getL10NFactory')) {
54
				$l = $c->query('ServerContainer')->getL10NFactory()->get('bookmarks');
55
			} else {
56
				// OC 8.1 compatibility
57
				$l = new \OC_L10N('bookmarks');
58
			}
59
60
			/** @var IContainer $c */
61
			return new BookmarkController(
62
				$c->query('AppName'),
63
				$c->query('Request'),
64
				$c->query('ServerContainer')->getUserSession()->getUser()->getUID(),
65
				$c->query('ServerContainer')->getDb(),
66
				$l
67
			);
68
		});
69
70
		$container->registerService('TagsController', function($c) {
71
			/** @var IContainer $c */
72
			return new TagsController(
73
				$c->query('AppName'),
74
				$c->query('Request'),
75
				$c->query('ServerContainer')->getUserSession()->getUser()->getUID(),
76
				$c->query('ServerContainer')->getDb()
77
			);
78
		});
79
80
		$container->registerService('PublicController', function($c) {
81
			/** @var IContainer $c */
82
			return new PublicController(
83
				$c->query('AppName'),
84
				$c->query('Request'),
85
				$c->query('ServerContainer')->getDb(),
86
				$c->query('ServerContainer')->getUserManager()
87
			);
88
		});
89
90
	}
91
92
}
93