Completed
Push — master ( e7a609...6d1b90 )
by Thomas
31:06 queued 17:33
created

Application::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 187
Code Lines 127

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 127
nc 1
nop 1
dl 0
loc 187
rs 8.2857
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * @author Björn Schießle <[email protected]>
4
 * @author Christoph Wurst <[email protected]>
5
 * @author Georg Ehrke <[email protected]>
6
 * @author Joas Schilling <[email protected]>
7
 * @author Lukas Reschke <[email protected]>
8
 * @author Morris Jobke <[email protected]>
9
 * @author Robin Appelman <[email protected]>
10
 * @author Roeland Jago Douma <[email protected]>
11
 * @author Thomas Müller <[email protected]>
12
 * @author Tom Needham <[email protected]>
13
 * @author Ujjwal Bhardwaj <[email protected]>
14
 *
15
 * @copyright Copyright (c) 2018, ownCloud GmbH
16
 * @license AGPL-3.0
17
 *
18
 * This code is free software: you can redistribute it and/or modify
19
 * it under the terms of the GNU Affero General Public License, version 3,
20
 * as published by the Free Software Foundation.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
 * GNU Affero General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU Affero General Public License, version 3,
28
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
29
 *
30
 */
31
32
namespace OC\Settings;
33
34
use OC\Server;
35
use OC\AppFramework\Utility\TimeFactory;
36
use OC\Settings\Controller\CorsController;
37
use OC\Settings\Controller\SettingsPageController;
38
use OC\Settings\Controller\AppSettingsController;
39
use OC\Settings\Controller\AuthSettingsController;
40
use OC\Settings\Controller\CertificateController;
41
use OC\Settings\Controller\CheckSetupController;
42
use OC\Settings\Controller\GroupsController;
43
use OC\Settings\Controller\LogSettingsController;
44
use OC\Settings\Controller\MailSettingsController;
45
use OC\Settings\Controller\UsersController;
46
use OC\Settings\Middleware\SubadminMiddleware;
47
use OCP\AppFramework\App;
48
use OCP\IContainer;
49
use OCP\Util;
50
51
/**
52
 * @package OC\Settings
53
 */
54
class Application extends App {
55
56
	/**
57
	 * @param array $urlParams
58
	 */
59
	public function __construct(array $urlParams=[]){
60
		parent::__construct('settings', $urlParams);
61
62
		$container = $this->getContainer();
63
64
		$container->registerService('Profile', function(IContainer $c) {
65
		   return new \OC\Settings\Panels\Personal\Profile(
0 ignored issues
show
Bug introduced by
The call to Profile::__construct() misses a required argument $lfactory.

This check looks for function calls that miss required arguments.

Loading history...
66
			   $c->query('Config'),
67
			   $c->query('GroupManager'),
68
			   $c->query('ServerContainer')->getURLGenerator()
69
		   );
70
	   });
71
72
		/**
73
		 * Controllers
74
		 */
75
		 $container->registerService('SettingsPageController', function(IContainer $c) {
76
 			return new SettingsPageController(
77
 				$c->query('AppName'),
78
				$c->query('Request'),
79
				$c->query('SettingsManager'),
80
				$c->query('ServerContainer')->getURLGenerator(),
81
				$c->query('GroupManager'),
82
				$c->query('UserSession')
83
 			);
84
 		});
85
		$container->registerService('MailSettingsController', function(IContainer $c) {
86
			return new MailSettingsController(
87
				$c->query('AppName'),
88
				$c->query('Request'),
89
				$c->query('L10N'),
90
				$c->query('Config'),
91
				$c->query('UserSession'),
92
				$c->query('Defaults'),
93
				$c->query('Mailer'),
94
				$c->query('DefaultMailAddress')
95
			);
96
		});
97
		$container->registerService('AppSettingsController', function(IContainer $c) {
98
			return new AppSettingsController(
99
				$c->query('AppName'),
100
				$c->query('Request'),
101
				$c->query('L10N'),
102
				$c->query('Config'),
103
				$c->query('IAppManager')
104
			);
105
		});
106
		$container->registerService('AuthSettingsController', function(IContainer $c) {
107
			return new AuthSettingsController(
108
				$c->query('AppName'),
109
				$c->query('Request'),
110
				$c->query('ServerContainer')->query('OC\Authentication\Token\IProvider'),
111
				$c->query('UserManager'),
112
				$c->query('ServerContainer')->getSession(),
113
				$c->query('ServerContainer')->getSecureRandom(),
114
				$c->query('UserId')
115
			);
116
		});
117
		$container->registerService('CertificateController', function(IContainer $c) {
118
			return new CertificateController(
119
				$c->query('AppName'),
120
				$c->query('Request'),
121
				$c->query('CertificateManager'),
122
				$c->query('SystemCertificateManager'),
123
				$c->query('L10N'),
124
				$c->query('IAppManager')
125
			);
126
		});
127
		$container->registerService('LogSettingsController', function(IContainer $c) {
128
			return new LogSettingsController(
129
				$c->query('AppName'),
130
				$c->query('Request'),
131
				$c->query('Config'),
132
				$c->query('L10N')
133
			);
134
		});
135
		$container->registerService('CheckSetupController', function(IContainer $c) {
136
			return new CheckSetupController(
137
				$c->query('AppName'),
138
				$c->query('Request'),
139
				$c->query('Config'),
140
				$c->query('ClientService'),
141
				$c->query('URLGenerator'),
142
				$c->query('Util'),
143
				$c->query('L10N'),
144
				$c->query('Checker')
145
			);
146
		});
147
		$container->registerService('CorsController', function(IContainer $c) {
148
			return new CorsController(
149
				$c->query('AppName'),
150
				$c->query('Request'),
151
				$c->query('UserSession'),
152
				$c->query('Logger'),
153
				$c->query('URLGenerator'),
154
				$c->query('Config')
155
			);
156
		});
157
158
		/**
159
		 * Middleware
160
		 */
161
		$container->registerService('SubadminMiddleware', function(IContainer $c){
162
			return new SubadminMiddleware(
163
				$c->query('ControllerMethodReflector'),
164
				$c->query('GroupManager'),
165
				$c->query('UserSession')
166
			);
167
		});
168
		// Execute middlewares
169
		$container->registerMiddleware('SubadminMiddleware');
170
171
		/**
172
		 * Core class wrappers
173
		 */
174
		$container->registerService('Config', function(IContainer $c) {
175
			return $c->query('ServerContainer')->getConfig();
176
		});
177
		$container->registerService('ICacheFactory', function(IContainer $c) {
178
			return $c->query('ServerContainer')->getMemCacheFactory();
179
		});
180
		$container->registerService('L10N', function(IContainer $c) {
181
			return $c->query('ServerContainer')->getL10N('settings');
182
		});
183
		$container->registerService('GroupManager', function(IContainer $c) {
184
			return $c->query('ServerContainer')->getGroupManager();
185
		});
186
		$container->registerService('UserManager', function(IContainer $c) {
187
			return $c->query('ServerContainer')->getUserManager();
188
		});
189
		$container->registerService('UserSession', function(IContainer $c) {
190
			return $c->query('ServerContainer')->getUserSession();
191
		});
192
		$container->registerService('Mailer', function(IContainer $c) {
193
			return $c->query('ServerContainer')->getMailer();
194
		});
195
		$container->registerService('Defaults', function(IContainer $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
196
			return new \OC_Defaults;
197
		});
198
		$container->registerService('DefaultMailAddress', function(IContainer $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
199
			return Util::getDefaultEmailAddress('no-reply');
200
		});
201
		$container->registerService('Logger', function(IContainer $c) {
202
			return $c->query('ServerContainer')->getLogger();
203
		});
204
		$container->registerService('URLGenerator', function(IContainer $c) {
205
			return $c->query('ServerContainer')->getURLGenerator();
206
		});
207
		$container->registerService('ClientService', function(IContainer $c) {
208
			return $c->query('ServerContainer')->getHTTPClientService();
209
		});
210
		$container->registerService('INavigationManager', function(IContainer $c) {
211
			return $c->query('ServerContainer')->getNavigationManager();
212
		});
213
		$container->registerService('IAppManager', function(IContainer $c) {
214
			return $c->query('ServerContainer')->getAppManager();
215
		});
216
		$container->registerService('OcsClient', function(IContainer $c) {
217
			return $c->query('ServerContainer')->getOcsClient();
218
		});
219
		$container->registerService('Util', function(IContainer $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
220
			return new \OC_Util();
221
		});
222
		$container->registerService('DatabaseConnection', function(IContainer $c) {
223
			return $c->query('ServerContainer')->getDatabaseConnection();
224
		});
225
		$container->registerService('CertificateManager', function(IContainer $c){
226
			return $c->query('ServerContainer')->getCertificateManager();
227
		});
228
		$container->registerService('SystemCertificateManager', function (IContainer $c) {
229
			return $c->query('ServerContainer')->getCertificateManager(null);
230
		});
231
		$container->registerService('Checker', function(IContainer $c) {
232
			/** @var Server $server */
233
			$server = $c->query('ServerContainer');
234
			return $server->getIntegrityCodeChecker();
235
		});
236
		$container->registerService('TimeFactory', function(IContainer $c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
237
			return new TimeFactory();
238
		});
239
		$container->registerService('SecureRandom', function(IContainer $c) {
240
			return $c->query('ServerContainer')->getSecureRandom();
241
		});
242
		$container->registerService('SettingsManager', function(IContainer $c) {
243
			return $c->query('ServerContainer')->getSettingsManager();
244
	 	});
245
	}
246
}
247