Completed
Pull Request — master (#3977)
by Joas
12:42
created
lib/private/AppFramework/DependencyInjection/DIContainer.php 2 patches
Indentation   +330 added lines, -330 removed lines patch added patch discarded remove patch
@@ -60,334 +60,334 @@
 block discarded – undo
60 60
 
61 61
 class DIContainer extends SimpleContainer implements IAppContainer {
62 62
 
63
-	/**
64
-	 * @var array
65
-	 */
66
-	private $middleWares = array();
67
-
68
-	/** @var ServerContainer */
69
-	private $server;
70
-
71
-	/**
72
-	 * Put your class dependencies in here
73
-	 * @param string $appName the name of the app
74
-	 * @param array $urlParams
75
-	 * @param ServerContainer $server
76
-	 */
77
-	public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
78
-		parent::__construct();
79
-		$this['AppName'] = $appName;
80
-		$this['urlParams'] = $urlParams;
81
-
82
-		/** @var \OC\ServerContainer $server */
83
-		if ($server === null) {
84
-			$server = \OC::$server;
85
-		}
86
-		$this->server = $server;
87
-		$this->server->registerAppContainer($appName, $this);
88
-
89
-		// aliases
90
-		$this->registerAlias('appName', 'AppName');
91
-		$this->registerAlias('webRoot', 'WebRoot');
92
-		$this->registerAlias('userId', 'UserId');
93
-
94
-		/**
95
-		 * Core services
96
-		 */
97
-		$this->registerService(IOutput::class, function($c){
98
-			return new Output($this->getServer()->getWebRoot());
99
-		});
100
-
101
-		$this->registerService(Folder::class, function() {
102
-			return $this->getServer()->getUserFolder();
103
-		});
104
-
105
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
106
-			return $this->getServer()->getAppDataDir($c->query('AppName'));
107
-		});
108
-
109
-		$this->registerService(IL10N::class, function($c) {
110
-			return $this->getServer()->getL10N($c->query('AppName'));
111
-		});
112
-
113
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
114
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
115
-
116
-		$this->registerService(IRequest::class, function() {
117
-			return $this->getServer()->query(IRequest::class);
118
-		});
119
-		$this->registerAlias('Request', IRequest::class);
120
-
121
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
122
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
123
-
124
-		$this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
125
-
126
-		$this->registerService(IServerContainer::class, function ($c) {
127
-			return $this->getServer();
128
-		});
129
-		$this->registerAlias('ServerContainer', IServerContainer::class);
130
-
131
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
132
-			return $c->query('OCA\WorkflowEngine\Manager');
133
-		});
134
-
135
-		$this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
136
-			return $c;
137
-		});
138
-
139
-		// commonly used attributes
140
-		$this->registerService('UserId', function ($c) {
141
-			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
142
-		});
143
-
144
-		$this->registerService('WebRoot', function ($c) {
145
-			return $c->query('ServerContainer')->getWebRoot();
146
-		});
147
-
148
-		$this->registerService('fromMailAddress', function() {
149
-			return Util::getDefaultEmailAddress('no-reply');
150
-		});
151
-
152
-		$this->registerService('OC_Defaults', function ($c) {
153
-			return $c->getServer()->getThemingDefaults();
154
-		});
155
-
156
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
157
-			return $this->getServer()->getEncryptionManager();
158
-		});
159
-
160
-		$this->registerService(IValidator::class, function($c) {
161
-			return $c->query(Validator::class);
162
-		});
163
-
164
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
165
-			return new \OC\Security\IdentityProof\Manager(
166
-				$this->getServer()->getAppDataDir('identityproof'),
167
-				$this->getServer()->getCrypto()
168
-			);
169
-		});
170
-
171
-
172
-		/**
173
-		 * App Framework APIs
174
-		 */
175
-		$this->registerService('API', function($c){
176
-			$c->query('OCP\\ILogger')->debug(
177
-				'Accessing the API class is deprecated! Use the appropriate ' .
178
-				'services instead!'
179
-			);
180
-			return new API($c['AppName']);
181
-		});
182
-
183
-		$this->registerService('Protocol', function($c){
184
-			/** @var \OC\Server $server */
185
-			$server = $c->query('ServerContainer');
186
-			$protocol = $server->getRequest()->getHttpProtocol();
187
-			return new Http($_SERVER, $protocol);
188
-		});
189
-
190
-		$this->registerService('Dispatcher', function($c) {
191
-			return new Dispatcher(
192
-				$c['Protocol'],
193
-				$c['MiddlewareDispatcher'],
194
-				$c['ControllerMethodReflector'],
195
-				$c['Request']
196
-			);
197
-		});
198
-
199
-		/**
200
-		 * App Framework default arguments
201
-		 */
202
-		$this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
203
-		$this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
204
-		$this->registerParameter('corsMaxAge', 1728000);
205
-
206
-		/**
207
-		 * Middleware
208
-		 */
209
-		$app = $this;
210
-		$this->registerService('SecurityMiddleware', function($c) use ($app){
211
-			/** @var \OC\Server $server */
212
-			$server = $app->getServer();
213
-
214
-			return new SecurityMiddleware(
215
-				$c['Request'],
216
-				$c['ControllerMethodReflector'],
217
-				$server->getNavigationManager(),
218
-				$server->getURLGenerator(),
219
-				$server->getLogger(),
220
-				$server->getSession(),
221
-				$c['AppName'],
222
-				$app->isLoggedIn(),
223
-				$app->isAdminUser(),
224
-				$server->getContentSecurityPolicyManager(),
225
-				$server->getCsrfTokenManager(),
226
-				$server->getContentSecurityPolicyNonceManager(),
227
-				$server->getBruteForceThrottler()
228
-			);
229
-
230
-		});
231
-
232
-		$this->registerService('CORSMiddleware', function($c) {
233
-			return new CORSMiddleware(
234
-				$c['Request'],
235
-				$c['ControllerMethodReflector'],
236
-				$c->query(IUserSession::class),
237
-				$c->getServer()->getBruteForceThrottler()
238
-			);
239
-		});
240
-
241
-		$this->registerService('SessionMiddleware', function($c) use ($app) {
242
-			return new SessionMiddleware(
243
-				$c['Request'],
244
-				$c['ControllerMethodReflector'],
245
-				$app->getServer()->getSession()
246
-			);
247
-		});
248
-
249
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
250
-			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
251
-			$userSession = $app->getServer()->getUserSession();
252
-			$session = $app->getServer()->getSession();
253
-			$urlGenerator = $app->getServer()->getURLGenerator();
254
-			$reflector = $c['ControllerMethodReflector'];
255
-			$request = $app->getServer()->getRequest();
256
-			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
257
-		});
258
-
259
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
260
-			return new OCSMiddleware(
261
-				$c['Request']
262
-			);
263
-		});
264
-
265
-		$middleWares = &$this->middleWares;
266
-		$this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) {
267
-			$dispatcher = new MiddlewareDispatcher();
268
-			$dispatcher->registerMiddleware($c['CORSMiddleware']);
269
-			$dispatcher->registerMiddleware($c['OCSMiddleware']);
270
-			$dispatcher->registerMiddleware($c['SecurityMiddleware']);
271
-			$dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
272
-
273
-			foreach($middleWares as $middleWare) {
274
-				$dispatcher->registerMiddleware($c[$middleWare]);
275
-			}
276
-
277
-			$dispatcher->registerMiddleware($c['SessionMiddleware']);
278
-			return $dispatcher;
279
-		});
280
-
281
-	}
282
-
283
-
284
-	/**
285
-	 * @deprecated implements only deprecated methods
286
-	 * @return IApi
287
-	 */
288
-	function getCoreApi()
289
-	{
290
-		return $this->query('API');
291
-	}
292
-
293
-	/**
294
-	 * @return \OCP\IServerContainer
295
-	 */
296
-	function getServer()
297
-	{
298
-		return $this->server;
299
-	}
300
-
301
-	/**
302
-	 * @param string $middleWare
303
-	 * @return boolean|null
304
-	 */
305
-	function registerMiddleWare($middleWare) {
306
-		array_push($this->middleWares, $middleWare);
307
-	}
308
-
309
-	/**
310
-	 * used to return the appname of the set application
311
-	 * @return string the name of your application
312
-	 */
313
-	function getAppName() {
314
-		return $this->query('AppName');
315
-	}
316
-
317
-	/**
318
-	 * @deprecated use IUserSession->isLoggedIn()
319
-	 * @return boolean
320
-	 */
321
-	function isLoggedIn() {
322
-		return \OC::$server->getUserSession()->isLoggedIn();
323
-	}
324
-
325
-	/**
326
-	 * @deprecated use IGroupManager->isAdmin($userId)
327
-	 * @return boolean
328
-	 */
329
-	function isAdminUser() {
330
-		$uid = $this->getUserId();
331
-		return \OC_User::isAdminUser($uid);
332
-	}
333
-
334
-	private function getUserId() {
335
-		return $this->getServer()->getSession()->get('user_id');
336
-	}
337
-
338
-	/**
339
-	 * @deprecated use the ILogger instead
340
-	 * @param string $message
341
-	 * @param string $level
342
-	 * @return mixed
343
-	 */
344
-	function log($message, $level) {
345
-		switch($level){
346
-			case 'debug':
347
-				$level = \OCP\Util::DEBUG;
348
-				break;
349
-			case 'info':
350
-				$level = \OCP\Util::INFO;
351
-				break;
352
-			case 'warn':
353
-				$level = \OCP\Util::WARN;
354
-				break;
355
-			case 'fatal':
356
-				$level = \OCP\Util::FATAL;
357
-				break;
358
-			default:
359
-				$level = \OCP\Util::ERROR;
360
-				break;
361
-		}
362
-		\OCP\Util::writeLog($this->getAppName(), $message, $level);
363
-	}
364
-
365
-	/**
366
-	 * Register a capability
367
-	 *
368
-	 * @param string $serviceName e.g. 'OCA\Files\Capabilities'
369
-	 */
370
-	public function registerCapability($serviceName) {
371
-		$this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
372
-			return $this->query($serviceName);
373
-		});
374
-	}
375
-
376
-	public function query($name) {
377
-		$name = $this->sanitizeName($name);
378
-
379
-		if ($this->offsetExists($name)) {
380
-			return parent::query($name);
381
-		} else {
382
-			if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
383
-				return parent::query($name);
384
-			} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
385
-				return parent::query($name);
386
-			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
387
-				return parent::query($name);
388
-			}
389
-		}
390
-
391
-		return $this->getServer()->query($name);
392
-	}
63
+    /**
64
+     * @var array
65
+     */
66
+    private $middleWares = array();
67
+
68
+    /** @var ServerContainer */
69
+    private $server;
70
+
71
+    /**
72
+     * Put your class dependencies in here
73
+     * @param string $appName the name of the app
74
+     * @param array $urlParams
75
+     * @param ServerContainer $server
76
+     */
77
+    public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
78
+        parent::__construct();
79
+        $this['AppName'] = $appName;
80
+        $this['urlParams'] = $urlParams;
81
+
82
+        /** @var \OC\ServerContainer $server */
83
+        if ($server === null) {
84
+            $server = \OC::$server;
85
+        }
86
+        $this->server = $server;
87
+        $this->server->registerAppContainer($appName, $this);
88
+
89
+        // aliases
90
+        $this->registerAlias('appName', 'AppName');
91
+        $this->registerAlias('webRoot', 'WebRoot');
92
+        $this->registerAlias('userId', 'UserId');
93
+
94
+        /**
95
+         * Core services
96
+         */
97
+        $this->registerService(IOutput::class, function($c){
98
+            return new Output($this->getServer()->getWebRoot());
99
+        });
100
+
101
+        $this->registerService(Folder::class, function() {
102
+            return $this->getServer()->getUserFolder();
103
+        });
104
+
105
+        $this->registerService(IAppData::class, function (SimpleContainer $c) {
106
+            return $this->getServer()->getAppDataDir($c->query('AppName'));
107
+        });
108
+
109
+        $this->registerService(IL10N::class, function($c) {
110
+            return $this->getServer()->getL10N($c->query('AppName'));
111
+        });
112
+
113
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
114
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
115
+
116
+        $this->registerService(IRequest::class, function() {
117
+            return $this->getServer()->query(IRequest::class);
118
+        });
119
+        $this->registerAlias('Request', IRequest::class);
120
+
121
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
122
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
123
+
124
+        $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
125
+
126
+        $this->registerService(IServerContainer::class, function ($c) {
127
+            return $this->getServer();
128
+        });
129
+        $this->registerAlias('ServerContainer', IServerContainer::class);
130
+
131
+        $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
132
+            return $c->query('OCA\WorkflowEngine\Manager');
133
+        });
134
+
135
+        $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
136
+            return $c;
137
+        });
138
+
139
+        // commonly used attributes
140
+        $this->registerService('UserId', function ($c) {
141
+            return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
142
+        });
143
+
144
+        $this->registerService('WebRoot', function ($c) {
145
+            return $c->query('ServerContainer')->getWebRoot();
146
+        });
147
+
148
+        $this->registerService('fromMailAddress', function() {
149
+            return Util::getDefaultEmailAddress('no-reply');
150
+        });
151
+
152
+        $this->registerService('OC_Defaults', function ($c) {
153
+            return $c->getServer()->getThemingDefaults();
154
+        });
155
+
156
+        $this->registerService('OCP\Encryption\IManager', function ($c) {
157
+            return $this->getServer()->getEncryptionManager();
158
+        });
159
+
160
+        $this->registerService(IValidator::class, function($c) {
161
+            return $c->query(Validator::class);
162
+        });
163
+
164
+        $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
165
+            return new \OC\Security\IdentityProof\Manager(
166
+                $this->getServer()->getAppDataDir('identityproof'),
167
+                $this->getServer()->getCrypto()
168
+            );
169
+        });
170
+
171
+
172
+        /**
173
+         * App Framework APIs
174
+         */
175
+        $this->registerService('API', function($c){
176
+            $c->query('OCP\\ILogger')->debug(
177
+                'Accessing the API class is deprecated! Use the appropriate ' .
178
+                'services instead!'
179
+            );
180
+            return new API($c['AppName']);
181
+        });
182
+
183
+        $this->registerService('Protocol', function($c){
184
+            /** @var \OC\Server $server */
185
+            $server = $c->query('ServerContainer');
186
+            $protocol = $server->getRequest()->getHttpProtocol();
187
+            return new Http($_SERVER, $protocol);
188
+        });
189
+
190
+        $this->registerService('Dispatcher', function($c) {
191
+            return new Dispatcher(
192
+                $c['Protocol'],
193
+                $c['MiddlewareDispatcher'],
194
+                $c['ControllerMethodReflector'],
195
+                $c['Request']
196
+            );
197
+        });
198
+
199
+        /**
200
+         * App Framework default arguments
201
+         */
202
+        $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
203
+        $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
204
+        $this->registerParameter('corsMaxAge', 1728000);
205
+
206
+        /**
207
+         * Middleware
208
+         */
209
+        $app = $this;
210
+        $this->registerService('SecurityMiddleware', function($c) use ($app){
211
+            /** @var \OC\Server $server */
212
+            $server = $app->getServer();
213
+
214
+            return new SecurityMiddleware(
215
+                $c['Request'],
216
+                $c['ControllerMethodReflector'],
217
+                $server->getNavigationManager(),
218
+                $server->getURLGenerator(),
219
+                $server->getLogger(),
220
+                $server->getSession(),
221
+                $c['AppName'],
222
+                $app->isLoggedIn(),
223
+                $app->isAdminUser(),
224
+                $server->getContentSecurityPolicyManager(),
225
+                $server->getCsrfTokenManager(),
226
+                $server->getContentSecurityPolicyNonceManager(),
227
+                $server->getBruteForceThrottler()
228
+            );
229
+
230
+        });
231
+
232
+        $this->registerService('CORSMiddleware', function($c) {
233
+            return new CORSMiddleware(
234
+                $c['Request'],
235
+                $c['ControllerMethodReflector'],
236
+                $c->query(IUserSession::class),
237
+                $c->getServer()->getBruteForceThrottler()
238
+            );
239
+        });
240
+
241
+        $this->registerService('SessionMiddleware', function($c) use ($app) {
242
+            return new SessionMiddleware(
243
+                $c['Request'],
244
+                $c['ControllerMethodReflector'],
245
+                $app->getServer()->getSession()
246
+            );
247
+        });
248
+
249
+        $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
250
+            $twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
251
+            $userSession = $app->getServer()->getUserSession();
252
+            $session = $app->getServer()->getSession();
253
+            $urlGenerator = $app->getServer()->getURLGenerator();
254
+            $reflector = $c['ControllerMethodReflector'];
255
+            $request = $app->getServer()->getRequest();
256
+            return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
257
+        });
258
+
259
+        $this->registerService('OCSMiddleware', function (SimpleContainer $c) {
260
+            return new OCSMiddleware(
261
+                $c['Request']
262
+            );
263
+        });
264
+
265
+        $middleWares = &$this->middleWares;
266
+        $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) {
267
+            $dispatcher = new MiddlewareDispatcher();
268
+            $dispatcher->registerMiddleware($c['CORSMiddleware']);
269
+            $dispatcher->registerMiddleware($c['OCSMiddleware']);
270
+            $dispatcher->registerMiddleware($c['SecurityMiddleware']);
271
+            $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
272
+
273
+            foreach($middleWares as $middleWare) {
274
+                $dispatcher->registerMiddleware($c[$middleWare]);
275
+            }
276
+
277
+            $dispatcher->registerMiddleware($c['SessionMiddleware']);
278
+            return $dispatcher;
279
+        });
280
+
281
+    }
282
+
283
+
284
+    /**
285
+     * @deprecated implements only deprecated methods
286
+     * @return IApi
287
+     */
288
+    function getCoreApi()
289
+    {
290
+        return $this->query('API');
291
+    }
292
+
293
+    /**
294
+     * @return \OCP\IServerContainer
295
+     */
296
+    function getServer()
297
+    {
298
+        return $this->server;
299
+    }
300
+
301
+    /**
302
+     * @param string $middleWare
303
+     * @return boolean|null
304
+     */
305
+    function registerMiddleWare($middleWare) {
306
+        array_push($this->middleWares, $middleWare);
307
+    }
308
+
309
+    /**
310
+     * used to return the appname of the set application
311
+     * @return string the name of your application
312
+     */
313
+    function getAppName() {
314
+        return $this->query('AppName');
315
+    }
316
+
317
+    /**
318
+     * @deprecated use IUserSession->isLoggedIn()
319
+     * @return boolean
320
+     */
321
+    function isLoggedIn() {
322
+        return \OC::$server->getUserSession()->isLoggedIn();
323
+    }
324
+
325
+    /**
326
+     * @deprecated use IGroupManager->isAdmin($userId)
327
+     * @return boolean
328
+     */
329
+    function isAdminUser() {
330
+        $uid = $this->getUserId();
331
+        return \OC_User::isAdminUser($uid);
332
+    }
333
+
334
+    private function getUserId() {
335
+        return $this->getServer()->getSession()->get('user_id');
336
+    }
337
+
338
+    /**
339
+     * @deprecated use the ILogger instead
340
+     * @param string $message
341
+     * @param string $level
342
+     * @return mixed
343
+     */
344
+    function log($message, $level) {
345
+        switch($level){
346
+            case 'debug':
347
+                $level = \OCP\Util::DEBUG;
348
+                break;
349
+            case 'info':
350
+                $level = \OCP\Util::INFO;
351
+                break;
352
+            case 'warn':
353
+                $level = \OCP\Util::WARN;
354
+                break;
355
+            case 'fatal':
356
+                $level = \OCP\Util::FATAL;
357
+                break;
358
+            default:
359
+                $level = \OCP\Util::ERROR;
360
+                break;
361
+        }
362
+        \OCP\Util::writeLog($this->getAppName(), $message, $level);
363
+    }
364
+
365
+    /**
366
+     * Register a capability
367
+     *
368
+     * @param string $serviceName e.g. 'OCA\Files\Capabilities'
369
+     */
370
+    public function registerCapability($serviceName) {
371
+        $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
372
+            return $this->query($serviceName);
373
+        });
374
+    }
375
+
376
+    public function query($name) {
377
+        $name = $this->sanitizeName($name);
378
+
379
+        if ($this->offsetExists($name)) {
380
+            return parent::query($name);
381
+        } else {
382
+            if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
383
+                return parent::query($name);
384
+            } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
385
+                return parent::query($name);
386
+            } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
387
+                return parent::query($name);
388
+            }
389
+        }
390
+
391
+        return $this->getServer()->query($name);
392
+    }
393 393
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param array $urlParams
75 75
 	 * @param ServerContainer $server
76 76
 	 */
77
-	public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
77
+	public function __construct($appName, $urlParams = array(), ServerContainer $server = null) {
78 78
 		parent::__construct();
79 79
 		$this['AppName'] = $appName;
80 80
 		$this['urlParams'] = $urlParams;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		/**
95 95
 		 * Core services
96 96
 		 */
97
-		$this->registerService(IOutput::class, function($c){
97
+		$this->registerService(IOutput::class, function($c) {
98 98
 			return new Output($this->getServer()->getWebRoot());
99 99
 		});
100 100
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 			return $this->getServer()->getUserFolder();
103 103
 		});
104 104
 
105
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
105
+		$this->registerService(IAppData::class, function(SimpleContainer $c) {
106 106
 			return $this->getServer()->getAppDataDir($c->query('AppName'));
107 107
 		});
108 108
 
@@ -123,25 +123,25 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
125 125
 
126
-		$this->registerService(IServerContainer::class, function ($c) {
126
+		$this->registerService(IServerContainer::class, function($c) {
127 127
 			return $this->getServer();
128 128
 		});
129 129
 		$this->registerAlias('ServerContainer', IServerContainer::class);
130 130
 
131
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
131
+		$this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) {
132 132
 			return $c->query('OCA\WorkflowEngine\Manager');
133 133
 		});
134 134
 
135
-		$this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
135
+		$this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) {
136 136
 			return $c;
137 137
 		});
138 138
 
139 139
 		// commonly used attributes
140
-		$this->registerService('UserId', function ($c) {
140
+		$this->registerService('UserId', function($c) {
141 141
 			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
142 142
 		});
143 143
 
144
-		$this->registerService('WebRoot', function ($c) {
144
+		$this->registerService('WebRoot', function($c) {
145 145
 			return $c->query('ServerContainer')->getWebRoot();
146 146
 		});
147 147
 
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 			return Util::getDefaultEmailAddress('no-reply');
150 150
 		});
151 151
 
152
-		$this->registerService('OC_Defaults', function ($c) {
152
+		$this->registerService('OC_Defaults', function($c) {
153 153
 			return $c->getServer()->getThemingDefaults();
154 154
 		});
155 155
 
156
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
156
+		$this->registerService('OCP\Encryption\IManager', function($c) {
157 157
 			return $this->getServer()->getEncryptionManager();
158 158
 		});
159 159
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 			return $c->query(Validator::class);
162 162
 		});
163 163
 
164
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
164
+		$this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) {
165 165
 			return new \OC\Security\IdentityProof\Manager(
166 166
 				$this->getServer()->getAppDataDir('identityproof'),
167 167
 				$this->getServer()->getCrypto()
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
 		/**
173 173
 		 * App Framework APIs
174 174
 		 */
175
-		$this->registerService('API', function($c){
175
+		$this->registerService('API', function($c) {
176 176
 			$c->query('OCP\\ILogger')->debug(
177
-				'Accessing the API class is deprecated! Use the appropriate ' .
177
+				'Accessing the API class is deprecated! Use the appropriate '.
178 178
 				'services instead!'
179 179
 			);
180 180
 			return new API($c['AppName']);
181 181
 		});
182 182
 
183
-		$this->registerService('Protocol', function($c){
183
+		$this->registerService('Protocol', function($c) {
184 184
 			/** @var \OC\Server $server */
185 185
 			$server = $c->query('ServerContainer');
186 186
 			$protocol = $server->getRequest()->getHttpProtocol();
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			);
247 247
 		});
248 248
 
249
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
249
+		$this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) {
250 250
 			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
251 251
 			$userSession = $app->getServer()->getUserSession();
252 252
 			$session = $app->getServer()->getSession();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
257 257
 		});
258 258
 
259
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
259
+		$this->registerService('OCSMiddleware', function(SimpleContainer $c) {
260 260
 			return new OCSMiddleware(
261 261
 				$c['Request']
262 262
 			);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			$dispatcher->registerMiddleware($c['SecurityMiddleware']);
271 271
 			$dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
272 272
 
273
-			foreach($middleWares as $middleWare) {
273
+			foreach ($middleWares as $middleWare) {
274 274
 				$dispatcher->registerMiddleware($c[$middleWare]);
275 275
 			}
276 276
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 * @return mixed
343 343
 	 */
344 344
 	function log($message, $level) {
345
-		switch($level){
345
+		switch ($level) {
346 346
 			case 'debug':
347 347
 				$level = \OCP\Util::DEBUG;
348 348
 				break;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 				return parent::query($name);
384 384
 			} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
385 385
 				return parent::query($name);
386
-			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
386
+			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) {
387 387
 				return parent::query($name);
388 388
 			}
389 389
 		}
Please login to merge, or discard this patch.