Completed
Push — master ( 68735c...ea470f )
by Björn
11:25
created

Application::getFederatedShareProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Björn Schießle <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2016, 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\FederatedFileSharing\AppInfo;
24
25
26
use OCA\FederatedFileSharing\FederatedShareProvider;
27
use OCP\AppFramework\App;
28
29
class Application extends App {
30
31
	/** @var FederatedShareProvider */
32
	protected $federatedShareProvider;
33
34
	public function __construct() {
35
		parent::__construct('federatedfilesharing');
36
	}
37
38
	/**
39
	 * register personal and admin settings page
40
	 */
41
	public function registerSettings() {
42
		\OCP\App::registerAdmin('federatedfilesharing', 'settings-admin');
43
		\OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
44
	}
45
46
	/**
47
	 * get instance of federated share provider
48
	 *
49
	 * @return FederatedShareProvider
50
	 */
51
	public function getFederatedShareProvider() {
52
		if ($this->federatedShareProvider === null) {
53
			$this->initFederatedShareProvider();
54
		}
55
		return $this->federatedShareProvider;
56
	}
57
58
	/**
59
	 * initialize federated share provider
60
	 */
61
	protected function initFederatedShareProvider() {
62
		$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
63
			\OC::$server->getURLGenerator(),
64
			\OC::$server->getL10N('federatedfilesharing')
65
		);
66
		$discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
67
			\OC::$server->getMemCacheFactory(),
68
			\OC::$server->getHTTPClientService()
69
		);
70
		$notifications = new \OCA\FederatedFileSharing\Notifications(
71
			$addressHandler,
72
			\OC::$server->getHTTPClientService(),
73
			$discoveryManager,
74
			\OC::$server->getJobList()
75
		);
76
		$tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
77
			\OC::$server->getSecureRandom()
78
		);
79
80
		$this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
81
			\OC::$server->getDatabaseConnection(),
82
			$addressHandler,
83
			$notifications,
84
			$tokenHandler,
85
			\OC::$server->getL10N('federatedfilesharing'),
86
			\OC::$server->getLogger(),
87
			\OC::$server->getLazyRootFolder(),
88
			\OC::$server->getConfig(),
89
			\OC::$server->getUserManager()
90
		);
91
	}
92
93
}
94