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