Completed
Pull Request — master (#3614)
by Björn
12:05
created
lib/private/AppFramework/DependencyInjection/DIContainer.php 2 patches
Indentation   +356 added lines, -356 removed lines patch added patch discarded remove patch
@@ -63,360 +63,360 @@
 block discarded – undo
63 63
 
64 64
 class DIContainer extends SimpleContainer implements IAppContainer {
65 65
 
66
-	/**
67
-	 * @var array
68
-	 */
69
-	private $middleWares = array();
70
-
71
-	/** @var ServerContainer */
72
-	private $server;
73
-
74
-	/**
75
-	 * Put your class dependencies in here
76
-	 * @param string $appName the name of the app
77
-	 * @param array $urlParams
78
-	 * @param ServerContainer $server
79
-	 */
80
-	public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
81
-		parent::__construct();
82
-		$this['AppName'] = $appName;
83
-		$this['urlParams'] = $urlParams;
84
-
85
-		/** @var \OC\ServerContainer $server */
86
-		if ($server === null) {
87
-			$server = \OC::$server;
88
-		}
89
-		$this->server = $server;
90
-		$this->server->registerAppContainer($appName, $this);
91
-
92
-		// aliases
93
-		$this->registerAlias('appName', 'AppName');
94
-		$this->registerAlias('webRoot', 'WebRoot');
95
-		$this->registerAlias('userId', 'UserId');
96
-
97
-		/**
98
-		 * Core services
99
-		 */
100
-		$this->registerService(IOutput::class, function($c){
101
-			return new Output($this->getServer()->getWebRoot());
102
-		});
103
-
104
-		$this->registerService(Folder::class, function() {
105
-			return $this->getServer()->getUserFolder();
106
-		});
107
-
108
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
109
-			return $this->getServer()->getAppDataDir($c->query('AppName'));
110
-		});
111
-
112
-		$this->registerService(IL10N::class, function($c) {
113
-			return $this->getServer()->getL10N($c->query('AppName'));
114
-		});
115
-
116
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
117
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
118
-
119
-		$this->registerService(IRequest::class, function() {
120
-			return $this->getServer()->query(IRequest::class);
121
-		});
122
-		$this->registerAlias('Request', IRequest::class);
123
-
124
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
125
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
126
-
127
-		$this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
128
-
129
-		$this->registerService(IServerContainer::class, function ($c) {
130
-			return $this->getServer();
131
-		});
132
-		$this->registerAlias('ServerContainer', IServerContainer::class);
133
-
134
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
135
-			return $c->query('OCA\WorkflowEngine\Manager');
136
-		});
137
-
138
-		$this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
139
-			return $c;
140
-		});
141
-
142
-		$this->registerService(IMountManager::class, function () {
143
-			return $this->getServer()->getMountManager();
144
-		});
145
-		$this->registerService(IDiscoveryService::class, function($c) {
146
-			return $this->getServer()->getOCSDiscoveryService();
147
-		});
148
-
149
-		// commonly used attributes
150
-		$this->registerService('UserId', function ($c) {
151
-			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
152
-		});
153
-
154
-		$this->registerService('WebRoot', function ($c) {
155
-			return $c->query('ServerContainer')->getWebRoot();
156
-		});
157
-
158
-		$this->registerService('fromMailAddress', function() {
159
-			return Util::getDefaultEmailAddress('no-reply');
160
-		});
161
-
162
-		$this->registerService('OC_Defaults', function ($c) {
163
-			return $c->getServer()->getThemingDefaults();
164
-		});
165
-
166
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
167
-			return $this->getServer()->getEncryptionManager();
168
-		});
169
-
170
-		$this->registerService(IValidator::class, function($c) {
171
-			return $c->query(Validator::class);
172
-		});
173
-
174
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
175
-			return new \OC\Security\IdentityProof\Manager(
176
-				$this->getServer()->getAppDataDir('identityproof'),
177
-				$this->getServer()->getCrypto()
178
-			);
179
-		});
180
-
181
-
182
-		/**
183
-		 * App Framework APIs
184
-		 */
185
-		$this->registerService('API', function($c){
186
-			$c->query('OCP\\ILogger')->debug(
187
-				'Accessing the API class is deprecated! Use the appropriate ' .
188
-				'services instead!'
189
-			);
190
-			return new API($c['AppName']);
191
-		});
192
-
193
-		$this->registerService('Protocol', function($c){
194
-			/** @var \OC\Server $server */
195
-			$server = $c->query('ServerContainer');
196
-			$protocol = $server->getRequest()->getHttpProtocol();
197
-			return new Http($_SERVER, $protocol);
198
-		});
199
-
200
-		$this->registerService('Dispatcher', function($c) {
201
-			return new Dispatcher(
202
-				$c['Protocol'],
203
-				$c['MiddlewareDispatcher'],
204
-				$c['ControllerMethodReflector'],
205
-				$c['Request']
206
-			);
207
-		});
208
-
209
-		/**
210
-		 * App Framework default arguments
211
-		 */
212
-		$this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
213
-		$this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
214
-		$this->registerParameter('corsMaxAge', 1728000);
215
-
216
-		/**
217
-		 * Middleware
218
-		 */
219
-		$app = $this;
220
-		$this->registerService('SecurityMiddleware', function($c) use ($app){
221
-			/** @var \OC\Server $server */
222
-			$server = $app->getServer();
223
-
224
-			return new SecurityMiddleware(
225
-				$c['Request'],
226
-				$c['ControllerMethodReflector'],
227
-				$server->getNavigationManager(),
228
-				$server->getURLGenerator(),
229
-				$server->getLogger(),
230
-				$server->getSession(),
231
-				$c['AppName'],
232
-				$app->isLoggedIn(),
233
-				$app->isAdminUser(),
234
-				$server->getContentSecurityPolicyManager(),
235
-				$server->getCsrfTokenManager(),
236
-				$server->getContentSecurityPolicyNonceManager(),
237
-				$server->getBruteForceThrottler()
238
-			);
239
-
240
-		});
241
-
242
-		$this->registerService('CORSMiddleware', function($c) {
243
-			return new CORSMiddleware(
244
-				$c['Request'],
245
-				$c['ControllerMethodReflector'],
246
-				$c->query(IUserSession::class),
247
-				$c->getServer()->getBruteForceThrottler()
248
-			);
249
-		});
250
-
251
-		$this->registerService('SessionMiddleware', function($c) use ($app) {
252
-			return new SessionMiddleware(
253
-				$c['Request'],
254
-				$c['ControllerMethodReflector'],
255
-				$app->getServer()->getSession()
256
-			);
257
-		});
258
-
259
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
260
-			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
261
-			$userSession = $app->getServer()->getUserSession();
262
-			$session = $app->getServer()->getSession();
263
-			$urlGenerator = $app->getServer()->getURLGenerator();
264
-			$reflector = $c['ControllerMethodReflector'];
265
-			$request = $app->getServer()->getRequest();
266
-			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
267
-		});
268
-
269
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
270
-			return new OCSMiddleware(
271
-				$c['Request']
272
-			);
273
-		});
274
-
275
-		$middleWares = &$this->middleWares;
276
-		$this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) {
277
-			$dispatcher = new MiddlewareDispatcher();
278
-			$dispatcher->registerMiddleware($c['CORSMiddleware']);
279
-			$dispatcher->registerMiddleware($c['OCSMiddleware']);
280
-			$dispatcher->registerMiddleware($c['SecurityMiddleware']);
281
-			$dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
282
-
283
-			foreach($middleWares as $middleWare) {
284
-				$dispatcher->registerMiddleware($c[$middleWare]);
285
-			}
286
-
287
-			$dispatcher->registerMiddleware($c['SessionMiddleware']);
288
-			return $dispatcher;
289
-		});
290
-
291
-	}
292
-
293
-
294
-	/**
295
-	 * @deprecated implements only deprecated methods
296
-	 * @return IApi
297
-	 */
298
-	function getCoreApi()
299
-	{
300
-		return $this->query('API');
301
-	}
302
-
303
-	/**
304
-	 * @return \OCP\IServerContainer
305
-	 */
306
-	function getServer()
307
-	{
308
-		return $this->server;
309
-	}
310
-
311
-	/**
312
-	 * @param string $middleWare
313
-	 * @return boolean|null
314
-	 */
315
-	function registerMiddleWare($middleWare) {
316
-		array_push($this->middleWares, $middleWare);
317
-	}
318
-
319
-	/**
320
-	 * used to return the appname of the set application
321
-	 * @return string the name of your application
322
-	 */
323
-	function getAppName() {
324
-		return $this->query('AppName');
325
-	}
326
-
327
-	/**
328
-	 * @deprecated use IUserSession->isLoggedIn()
329
-	 * @return boolean
330
-	 */
331
-	function isLoggedIn() {
332
-		return \OC::$server->getUserSession()->isLoggedIn();
333
-	}
334
-
335
-	/**
336
-	 * @deprecated use IGroupManager->isAdmin($userId)
337
-	 * @return boolean
338
-	 */
339
-	function isAdminUser() {
340
-		$uid = $this->getUserId();
341
-		return \OC_User::isAdminUser($uid);
342
-	}
343
-
344
-	private function getUserId() {
345
-		return $this->getServer()->getSession()->get('user_id');
346
-	}
347
-
348
-	/**
349
-	 * @deprecated use the ILogger instead
350
-	 * @param string $message
351
-	 * @param string $level
352
-	 * @return mixed
353
-	 */
354
-	function log($message, $level) {
355
-		switch($level){
356
-			case 'debug':
357
-				$level = \OCP\Util::DEBUG;
358
-				break;
359
-			case 'info':
360
-				$level = \OCP\Util::INFO;
361
-				break;
362
-			case 'warn':
363
-				$level = \OCP\Util::WARN;
364
-				break;
365
-			case 'fatal':
366
-				$level = \OCP\Util::FATAL;
367
-				break;
368
-			default:
369
-				$level = \OCP\Util::ERROR;
370
-				break;
371
-		}
372
-		\OCP\Util::writeLog($this->getAppName(), $message, $level);
373
-	}
374
-
375
-	/**
376
-	 * Register a capability
377
-	 *
378
-	 * @param string $serviceName e.g. 'OCA\Files\Capabilities'
379
-	 */
380
-	public function registerCapability($serviceName) {
381
-		$this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
382
-			return $this->query($serviceName);
383
-		});
384
-	}
385
-
386
-	/**
387
-	 * @param string $name
388
-	 * @return mixed
389
-	 * @throws QueryException if the query could not be resolved
390
-	 */
391
-	public function query($name) {
392
-		try {
393
-			return $this->queryNoFallback($name);
394
-		} catch (QueryException $e) {
395
-			return $this->getServer()->query($name);
396
-		}
397
-	}
398
-
399
-	/**
400
-	 * @param string $name
401
-	 * @return mixed
402
-	 * @throws QueryException if the query could not be resolved
403
-	 */
404
-	public function queryNoFallback($name) {
405
-		$name = $this->sanitizeName($name);
406
-
407
-		if ($this->offsetExists($name)) {
408
-			return parent::query($name);
409
-		} else {
410
-			if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
411
-				return parent::query($name);
412
-			} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
413
-				return parent::query($name);
414
-			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
415
-				return parent::query($name);
416
-			}
417
-		}
418
-
419
-		throw new QueryException('Could not resolve ' . $name . '!' .
420
-			' Class can not be instantiated');
421
-	}
66
+    /**
67
+     * @var array
68
+     */
69
+    private $middleWares = array();
70
+
71
+    /** @var ServerContainer */
72
+    private $server;
73
+
74
+    /**
75
+     * Put your class dependencies in here
76
+     * @param string $appName the name of the app
77
+     * @param array $urlParams
78
+     * @param ServerContainer $server
79
+     */
80
+    public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
81
+        parent::__construct();
82
+        $this['AppName'] = $appName;
83
+        $this['urlParams'] = $urlParams;
84
+
85
+        /** @var \OC\ServerContainer $server */
86
+        if ($server === null) {
87
+            $server = \OC::$server;
88
+        }
89
+        $this->server = $server;
90
+        $this->server->registerAppContainer($appName, $this);
91
+
92
+        // aliases
93
+        $this->registerAlias('appName', 'AppName');
94
+        $this->registerAlias('webRoot', 'WebRoot');
95
+        $this->registerAlias('userId', 'UserId');
96
+
97
+        /**
98
+         * Core services
99
+         */
100
+        $this->registerService(IOutput::class, function($c){
101
+            return new Output($this->getServer()->getWebRoot());
102
+        });
103
+
104
+        $this->registerService(Folder::class, function() {
105
+            return $this->getServer()->getUserFolder();
106
+        });
107
+
108
+        $this->registerService(IAppData::class, function (SimpleContainer $c) {
109
+            return $this->getServer()->getAppDataDir($c->query('AppName'));
110
+        });
111
+
112
+        $this->registerService(IL10N::class, function($c) {
113
+            return $this->getServer()->getL10N($c->query('AppName'));
114
+        });
115
+
116
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
117
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
118
+
119
+        $this->registerService(IRequest::class, function() {
120
+            return $this->getServer()->query(IRequest::class);
121
+        });
122
+        $this->registerAlias('Request', IRequest::class);
123
+
124
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
125
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
126
+
127
+        $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
128
+
129
+        $this->registerService(IServerContainer::class, function ($c) {
130
+            return $this->getServer();
131
+        });
132
+        $this->registerAlias('ServerContainer', IServerContainer::class);
133
+
134
+        $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
135
+            return $c->query('OCA\WorkflowEngine\Manager');
136
+        });
137
+
138
+        $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
139
+            return $c;
140
+        });
141
+
142
+        $this->registerService(IMountManager::class, function () {
143
+            return $this->getServer()->getMountManager();
144
+        });
145
+        $this->registerService(IDiscoveryService::class, function($c) {
146
+            return $this->getServer()->getOCSDiscoveryService();
147
+        });
148
+
149
+        // commonly used attributes
150
+        $this->registerService('UserId', function ($c) {
151
+            return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
152
+        });
153
+
154
+        $this->registerService('WebRoot', function ($c) {
155
+            return $c->query('ServerContainer')->getWebRoot();
156
+        });
157
+
158
+        $this->registerService('fromMailAddress', function() {
159
+            return Util::getDefaultEmailAddress('no-reply');
160
+        });
161
+
162
+        $this->registerService('OC_Defaults', function ($c) {
163
+            return $c->getServer()->getThemingDefaults();
164
+        });
165
+
166
+        $this->registerService('OCP\Encryption\IManager', function ($c) {
167
+            return $this->getServer()->getEncryptionManager();
168
+        });
169
+
170
+        $this->registerService(IValidator::class, function($c) {
171
+            return $c->query(Validator::class);
172
+        });
173
+
174
+        $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
175
+            return new \OC\Security\IdentityProof\Manager(
176
+                $this->getServer()->getAppDataDir('identityproof'),
177
+                $this->getServer()->getCrypto()
178
+            );
179
+        });
180
+
181
+
182
+        /**
183
+         * App Framework APIs
184
+         */
185
+        $this->registerService('API', function($c){
186
+            $c->query('OCP\\ILogger')->debug(
187
+                'Accessing the API class is deprecated! Use the appropriate ' .
188
+                'services instead!'
189
+            );
190
+            return new API($c['AppName']);
191
+        });
192
+
193
+        $this->registerService('Protocol', function($c){
194
+            /** @var \OC\Server $server */
195
+            $server = $c->query('ServerContainer');
196
+            $protocol = $server->getRequest()->getHttpProtocol();
197
+            return new Http($_SERVER, $protocol);
198
+        });
199
+
200
+        $this->registerService('Dispatcher', function($c) {
201
+            return new Dispatcher(
202
+                $c['Protocol'],
203
+                $c['MiddlewareDispatcher'],
204
+                $c['ControllerMethodReflector'],
205
+                $c['Request']
206
+            );
207
+        });
208
+
209
+        /**
210
+         * App Framework default arguments
211
+         */
212
+        $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH');
213
+        $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept');
214
+        $this->registerParameter('corsMaxAge', 1728000);
215
+
216
+        /**
217
+         * Middleware
218
+         */
219
+        $app = $this;
220
+        $this->registerService('SecurityMiddleware', function($c) use ($app){
221
+            /** @var \OC\Server $server */
222
+            $server = $app->getServer();
223
+
224
+            return new SecurityMiddleware(
225
+                $c['Request'],
226
+                $c['ControllerMethodReflector'],
227
+                $server->getNavigationManager(),
228
+                $server->getURLGenerator(),
229
+                $server->getLogger(),
230
+                $server->getSession(),
231
+                $c['AppName'],
232
+                $app->isLoggedIn(),
233
+                $app->isAdminUser(),
234
+                $server->getContentSecurityPolicyManager(),
235
+                $server->getCsrfTokenManager(),
236
+                $server->getContentSecurityPolicyNonceManager(),
237
+                $server->getBruteForceThrottler()
238
+            );
239
+
240
+        });
241
+
242
+        $this->registerService('CORSMiddleware', function($c) {
243
+            return new CORSMiddleware(
244
+                $c['Request'],
245
+                $c['ControllerMethodReflector'],
246
+                $c->query(IUserSession::class),
247
+                $c->getServer()->getBruteForceThrottler()
248
+            );
249
+        });
250
+
251
+        $this->registerService('SessionMiddleware', function($c) use ($app) {
252
+            return new SessionMiddleware(
253
+                $c['Request'],
254
+                $c['ControllerMethodReflector'],
255
+                $app->getServer()->getSession()
256
+            );
257
+        });
258
+
259
+        $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
260
+            $twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
261
+            $userSession = $app->getServer()->getUserSession();
262
+            $session = $app->getServer()->getSession();
263
+            $urlGenerator = $app->getServer()->getURLGenerator();
264
+            $reflector = $c['ControllerMethodReflector'];
265
+            $request = $app->getServer()->getRequest();
266
+            return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
267
+        });
268
+
269
+        $this->registerService('OCSMiddleware', function (SimpleContainer $c) {
270
+            return new OCSMiddleware(
271
+                $c['Request']
272
+            );
273
+        });
274
+
275
+        $middleWares = &$this->middleWares;
276
+        $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) {
277
+            $dispatcher = new MiddlewareDispatcher();
278
+            $dispatcher->registerMiddleware($c['CORSMiddleware']);
279
+            $dispatcher->registerMiddleware($c['OCSMiddleware']);
280
+            $dispatcher->registerMiddleware($c['SecurityMiddleware']);
281
+            $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
282
+
283
+            foreach($middleWares as $middleWare) {
284
+                $dispatcher->registerMiddleware($c[$middleWare]);
285
+            }
286
+
287
+            $dispatcher->registerMiddleware($c['SessionMiddleware']);
288
+            return $dispatcher;
289
+        });
290
+
291
+    }
292
+
293
+
294
+    /**
295
+     * @deprecated implements only deprecated methods
296
+     * @return IApi
297
+     */
298
+    function getCoreApi()
299
+    {
300
+        return $this->query('API');
301
+    }
302
+
303
+    /**
304
+     * @return \OCP\IServerContainer
305
+     */
306
+    function getServer()
307
+    {
308
+        return $this->server;
309
+    }
310
+
311
+    /**
312
+     * @param string $middleWare
313
+     * @return boolean|null
314
+     */
315
+    function registerMiddleWare($middleWare) {
316
+        array_push($this->middleWares, $middleWare);
317
+    }
318
+
319
+    /**
320
+     * used to return the appname of the set application
321
+     * @return string the name of your application
322
+     */
323
+    function getAppName() {
324
+        return $this->query('AppName');
325
+    }
326
+
327
+    /**
328
+     * @deprecated use IUserSession->isLoggedIn()
329
+     * @return boolean
330
+     */
331
+    function isLoggedIn() {
332
+        return \OC::$server->getUserSession()->isLoggedIn();
333
+    }
334
+
335
+    /**
336
+     * @deprecated use IGroupManager->isAdmin($userId)
337
+     * @return boolean
338
+     */
339
+    function isAdminUser() {
340
+        $uid = $this->getUserId();
341
+        return \OC_User::isAdminUser($uid);
342
+    }
343
+
344
+    private function getUserId() {
345
+        return $this->getServer()->getSession()->get('user_id');
346
+    }
347
+
348
+    /**
349
+     * @deprecated use the ILogger instead
350
+     * @param string $message
351
+     * @param string $level
352
+     * @return mixed
353
+     */
354
+    function log($message, $level) {
355
+        switch($level){
356
+            case 'debug':
357
+                $level = \OCP\Util::DEBUG;
358
+                break;
359
+            case 'info':
360
+                $level = \OCP\Util::INFO;
361
+                break;
362
+            case 'warn':
363
+                $level = \OCP\Util::WARN;
364
+                break;
365
+            case 'fatal':
366
+                $level = \OCP\Util::FATAL;
367
+                break;
368
+            default:
369
+                $level = \OCP\Util::ERROR;
370
+                break;
371
+        }
372
+        \OCP\Util::writeLog($this->getAppName(), $message, $level);
373
+    }
374
+
375
+    /**
376
+     * Register a capability
377
+     *
378
+     * @param string $serviceName e.g. 'OCA\Files\Capabilities'
379
+     */
380
+    public function registerCapability($serviceName) {
381
+        $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) {
382
+            return $this->query($serviceName);
383
+        });
384
+    }
385
+
386
+    /**
387
+     * @param string $name
388
+     * @return mixed
389
+     * @throws QueryException if the query could not be resolved
390
+     */
391
+    public function query($name) {
392
+        try {
393
+            return $this->queryNoFallback($name);
394
+        } catch (QueryException $e) {
395
+            return $this->getServer()->query($name);
396
+        }
397
+    }
398
+
399
+    /**
400
+     * @param string $name
401
+     * @return mixed
402
+     * @throws QueryException if the query could not be resolved
403
+     */
404
+    public function queryNoFallback($name) {
405
+        $name = $this->sanitizeName($name);
406
+
407
+        if ($this->offsetExists($name)) {
408
+            return parent::query($name);
409
+        } else {
410
+            if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
411
+                return parent::query($name);
412
+            } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
413
+                return parent::query($name);
414
+            } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
415
+                return parent::query($name);
416
+            }
417
+        }
418
+
419
+        throw new QueryException('Could not resolve ' . $name . '!' .
420
+            ' Class can not be instantiated');
421
+    }
422 422
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param array $urlParams
78 78
 	 * @param ServerContainer $server
79 79
 	 */
80
-	public function __construct($appName, $urlParams = array(), ServerContainer $server = null){
80
+	public function __construct($appName, $urlParams = array(), ServerContainer $server = null) {
81 81
 		parent::__construct();
82 82
 		$this['AppName'] = $appName;
83 83
 		$this['urlParams'] = $urlParams;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		/**
98 98
 		 * Core services
99 99
 		 */
100
-		$this->registerService(IOutput::class, function($c){
100
+		$this->registerService(IOutput::class, function($c) {
101 101
 			return new Output($this->getServer()->getWebRoot());
102 102
 		});
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			return $this->getServer()->getUserFolder();
106 106
 		});
107 107
 
108
-		$this->registerService(IAppData::class, function (SimpleContainer $c) {
108
+		$this->registerService(IAppData::class, function(SimpleContainer $c) {
109 109
 			return $this->getServer()->getAppDataDir($c->query('AppName'));
110 110
 		});
111 111
 
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 
127 127
 		$this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class);
128 128
 
129
-		$this->registerService(IServerContainer::class, function ($c) {
129
+		$this->registerService(IServerContainer::class, function($c) {
130 130
 			return $this->getServer();
131 131
 		});
132 132
 		$this->registerAlias('ServerContainer', IServerContainer::class);
133 133
 
134
-		$this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) {
134
+		$this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) {
135 135
 			return $c->query('OCA\WorkflowEngine\Manager');
136 136
 		});
137 137
 
138
-		$this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) {
138
+		$this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) {
139 139
 			return $c;
140 140
 		});
141 141
 
142
-		$this->registerService(IMountManager::class, function () {
142
+		$this->registerService(IMountManager::class, function() {
143 143
 			return $this->getServer()->getMountManager();
144 144
 		});
145 145
 		$this->registerService(IDiscoveryService::class, function($c) {
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 		});
148 148
 
149 149
 		// commonly used attributes
150
-		$this->registerService('UserId', function ($c) {
150
+		$this->registerService('UserId', function($c) {
151 151
 			return $c->query('OCP\\IUserSession')->getSession()->get('user_id');
152 152
 		});
153 153
 
154
-		$this->registerService('WebRoot', function ($c) {
154
+		$this->registerService('WebRoot', function($c) {
155 155
 			return $c->query('ServerContainer')->getWebRoot();
156 156
 		});
157 157
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 			return Util::getDefaultEmailAddress('no-reply');
160 160
 		});
161 161
 
162
-		$this->registerService('OC_Defaults', function ($c) {
162
+		$this->registerService('OC_Defaults', function($c) {
163 163
 			return $c->getServer()->getThemingDefaults();
164 164
 		});
165 165
 
166
-		$this->registerService('OCP\Encryption\IManager', function ($c) {
166
+		$this->registerService('OCP\Encryption\IManager', function($c) {
167 167
 			return $this->getServer()->getEncryptionManager();
168 168
 		});
169 169
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 			return $c->query(Validator::class);
172 172
 		});
173 173
 
174
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) {
174
+		$this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) {
175 175
 			return new \OC\Security\IdentityProof\Manager(
176 176
 				$this->getServer()->getAppDataDir('identityproof'),
177 177
 				$this->getServer()->getCrypto()
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 		/**
183 183
 		 * App Framework APIs
184 184
 		 */
185
-		$this->registerService('API', function($c){
185
+		$this->registerService('API', function($c) {
186 186
 			$c->query('OCP\\ILogger')->debug(
187
-				'Accessing the API class is deprecated! Use the appropriate ' .
187
+				'Accessing the API class is deprecated! Use the appropriate '.
188 188
 				'services instead!'
189 189
 			);
190 190
 			return new API($c['AppName']);
191 191
 		});
192 192
 
193
-		$this->registerService('Protocol', function($c){
193
+		$this->registerService('Protocol', function($c) {
194 194
 			/** @var \OC\Server $server */
195 195
 			$server = $c->query('ServerContainer');
196 196
 			$protocol = $server->getRequest()->getHttpProtocol();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			);
257 257
 		});
258 258
 
259
-		$this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) {
259
+		$this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) {
260 260
 			$twoFactorManager = $c->getServer()->getTwoFactorAuthManager();
261 261
 			$userSession = $app->getServer()->getUserSession();
262 262
 			$session = $app->getServer()->getSession();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 			return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request);
267 267
 		});
268 268
 
269
-		$this->registerService('OCSMiddleware', function (SimpleContainer $c) {
269
+		$this->registerService('OCSMiddleware', function(SimpleContainer $c) {
270 270
 			return new OCSMiddleware(
271 271
 				$c['Request']
272 272
 			);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 			$dispatcher->registerMiddleware($c['SecurityMiddleware']);
281 281
 			$dispatcher->registerMiddleWare($c['TwoFactorMiddleware']);
282 282
 
283
-			foreach($middleWares as $middleWare) {
283
+			foreach ($middleWares as $middleWare) {
284 284
 				$dispatcher->registerMiddleware($c[$middleWare]);
285 285
 			}
286 286
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @return mixed
353 353
 	 */
354 354
 	function log($message, $level) {
355
-		switch($level){
355
+		switch ($level) {
356 356
 			case 'debug':
357 357
 				$level = \OCP\Util::DEBUG;
358 358
 				break;
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 				return parent::query($name);
412 412
 			} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
413 413
 				return parent::query($name);
414
-			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) {
414
+			} else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) {
415 415
 				return parent::query($name);
416 416
 			}
417 417
 		}
418 418
 
419
-		throw new QueryException('Could not resolve ' . $name . '!' .
419
+		throw new QueryException('Could not resolve '.$name.'!'.
420 420
 			' Class can not be instantiated');
421 421
 	}
422 422
 }
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/SyncService.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -163,7 +163,6 @@  discard block
 block discarded – undo
163 163
 	/**
164 164
 	 * @param string $url
165 165
 	 * @param string $userName
166
-	 * @param string $addressBookUrl
167 166
 	 * @param string $sharedSecret
168 167
 	 * @return Client
169 168
 	 */
@@ -301,7 +300,7 @@  discard block
 block discarded – undo
301 300
 	}
302 301
 
303 302
 	/**
304
-	 * @return array|null
303
+	 * @return string
305 304
 	 */
306 305
 	public function getLocalSystemAddressBook() {
307 306
 		if (is_null($this->localSystemAddressBook)) {
Please login to merge, or discard this patch.
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -38,302 +38,302 @@
 block discarded – undo
38 38
 
39 39
 class SyncService {
40 40
 
41
-	/** @var CardDavBackend */
42
-	private $backend;
43
-
44
-	/** @var IUserManager */
45
-	private $userManager;
46
-
47
-	/** @var ILogger */
48
-	private $logger;
49
-
50
-	/** @var array */
51
-	private $localSystemAddressBook;
52
-
53
-	/** @var AccountManager */
54
-	private $accountManager;
55
-
56
-	/** @var string */
57
-	protected $certPath;
58
-
59
-	/**
60
-	 * SyncService constructor.
61
-	 *
62
-	 * @param CardDavBackend $backend
63
-	 * @param IUserManager $userManager
64
-	 * @param ILogger $logger
65
-	 * @param AccountManager $accountManager
66
-	 */
67
-	public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) {
68
-		$this->backend = $backend;
69
-		$this->userManager = $userManager;
70
-		$this->logger = $logger;
71
-		$this->accountManager = $accountManager;
72
-		$this->certPath = '';
73
-	}
74
-
75
-	/**
76
-	 * @param string $url
77
-	 * @param string $userName
78
-	 * @param string $addressBookUrl
79
-	 * @param string $sharedSecret
80
-	 * @param string $syncToken
81
-	 * @param int $targetBookId
82
-	 * @param string $targetPrincipal
83
-	 * @param array $targetProperties
84
-	 * @return string
85
-	 * @throws \Exception
86
-	 */
87
-	public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
88
-		// 1. create addressbook
89
-		$book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
90
-		$addressBookId = $book['id'];
91
-
92
-		// 2. query changes
93
-		try {
94
-			$response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken);
95
-		} catch (ClientHttpException $ex) {
96
-			if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
97
-				// remote server revoked access to the address book, remove it
98
-				$this->backend->deleteAddressBook($addressBookId);
99
-				$this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']);
100
-				throw $ex;
101
-			}
102
-		}
103
-
104
-		// 3. apply changes
105
-		// TODO: use multi-get for download
106
-		foreach ($response['response'] as $resource => $status) {
107
-			$cardUri = basename($resource);
108
-			if (isset($status[200])) {
109
-				$vCard = $this->download($url, $userName, $sharedSecret, $resource);
110
-				$existingCard = $this->backend->getCard($addressBookId, $cardUri);
111
-				if ($existingCard === false) {
112
-					$this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
113
-				} else {
114
-					$this->backend->updateCard($addressBookId, $cardUri, $vCard['body']);
115
-				}
116
-			} else {
117
-				$this->backend->deleteCard($addressBookId, $cardUri);
118
-			}
119
-		}
120
-
121
-		return $response['token'];
122
-	}
123
-
124
-	/**
125
-	 * @param string $principal
126
-	 * @param string $id
127
-	 * @param array $properties
128
-	 * @return array|null
129
-	 * @throws \Sabre\DAV\Exception\BadRequest
130
-	 */
131
-	public function ensureSystemAddressBookExists($principal, $id, $properties) {
132
-		$book = $this->backend->getAddressBooksByUri($principal, $id);
133
-		if (!is_null($book)) {
134
-			return $book;
135
-		}
136
-		$this->backend->createAddressBook($principal, $id, $properties);
137
-
138
-		return $this->backend->getAddressBooksByUri($principal, $id);
139
-	}
140
-
141
-	/**
142
-	 * Check if there is a valid certPath we should use
143
-	 *
144
-	 * @return string
145
-	 */
146
-	protected function getCertPath() {
147
-
148
-		// we already have a valid certPath
149
-		if ($this->certPath !== '') {
150
-			return $this->certPath;
151
-		}
152
-
153
-		/** @var ICertificateManager $certManager */
154
-		$certManager = \OC::$server->getCertificateManager(null);
155
-		$certPath = $certManager->getAbsoluteBundlePath();
156
-		if (file_exists($certPath)) {
157
-			$this->certPath = $certPath;
158
-		}
159
-
160
-		return $this->certPath;
161
-	}
162
-
163
-	/**
164
-	 * @param string $url
165
-	 * @param string $userName
166
-	 * @param string $addressBookUrl
167
-	 * @param string $sharedSecret
168
-	 * @return Client
169
-	 */
170
-	protected function getClient($url, $userName, $sharedSecret) {
171
-		$settings = [
172
-			'baseUri' => $url . '/',
173
-			'userName' => $userName,
174
-			'password' => $sharedSecret,
175
-		];
176
-		$client = new Client($settings);
177
-		$certPath = $this->getCertPath();
178
-		$client->setThrowExceptions(true);
179
-
180
-		if ($certPath !== '' && strpos($url, 'http://') !== 0) {
181
-			$client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
182
-		}
183
-
184
-		return $client;
185
-	}
186
-
187
-	/**
188
-	 * @param string $url
189
-	 * @param string $userName
190
-	 * @param string $addressBookUrl
191
-	 * @param string $sharedSecret
192
-	 * @param string $syncToken
193
-	 * @return array
194
-	 */
195
-	 protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
196
-		 $client = $this->getClient($url, $userName, $sharedSecret);
197
-
198
-		 $body = $this->buildSyncCollectionRequestBody($syncToken);
199
-
200
-		 $response = $client->request('REPORT', $addressBookUrl, $body, [
201
-			 'Content-Type' => 'application/xml'
202
-		 ]);
203
-
204
-		 return $this->parseMultiStatus($response['body']);
205
-	 }
206
-
207
-	/**
208
-	 * @param string $url
209
-	 * @param string $userName
210
-	 * @param string $sharedSecret
211
-	 * @param string $resourcePath
212
-	 * @return array
213
-	 */
214
-	protected function download($url, $userName, $sharedSecret, $resourcePath) {
215
-		$client = $this->getClient($url, $userName, $sharedSecret);
216
-		return $client->request('GET', $resourcePath);
217
-	}
218
-
219
-	/**
220
-	 * @param string|null $syncToken
221
-	 * @return string
222
-	 */
223
-	private function buildSyncCollectionRequestBody($syncToken) {
224
-
225
-		$dom = new \DOMDocument('1.0', 'UTF-8');
226
-		$dom->formatOutput = true;
227
-		$root = $dom->createElementNS('DAV:', 'd:sync-collection');
228
-		$sync = $dom->createElement('d:sync-token', $syncToken);
229
-		$prop = $dom->createElement('d:prop');
230
-		$cont = $dom->createElement('d:getcontenttype');
231
-		$etag = $dom->createElement('d:getetag');
232
-
233
-		$prop->appendChild($cont);
234
-		$prop->appendChild($etag);
235
-		$root->appendChild($sync);
236
-		$root->appendChild($prop);
237
-		$dom->appendChild($root);
238
-		$body = $dom->saveXML();
239
-
240
-		return $body;
241
-	}
242
-
243
-	/**
244
-	 * @param string $body
245
-	 * @return array
246
-	 * @throws \Sabre\Xml\ParseException
247
-	 */
248
-	private function parseMultiStatus($body) {
249
-		$xml = new Service();
250
-
251
-		/** @var MultiStatus $multiStatus */
252
-		$multiStatus = $xml->expect('{DAV:}multistatus', $body);
253
-
254
-		$result = [];
255
-		foreach ($multiStatus->getResponses() as $response) {
256
-			$result[$response->getHref()] = $response->getResponseProperties();
257
-		}
258
-
259
-		return ['response' => $result, 'token' => $multiStatus->getSyncToken()];
260
-	}
261
-
262
-	/**
263
-	 * @param IUser $user
264
-	 */
265
-	public function updateUser($user) {
266
-		$systemAddressBook = $this->getLocalSystemAddressBook();
267
-		$addressBookId = $systemAddressBook['id'];
268
-		$converter = new Converter($this->accountManager);
269
-		$name = $user->getBackendClassName();
270
-		$userId = $user->getUID();
271
-
272
-		$cardId = "$name:$userId.vcf";
273
-		$card = $this->backend->getCard($addressBookId, $cardId);
274
-		if ($card === false) {
275
-			$vCard = $converter->createCardFromUser($user);
276
-			if ($vCard !== null) {
277
-				$this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
278
-			}
279
-		} else {
280
-			$vCard = $converter->createCardFromUser($user);
281
-			if (is_null($vCard)) {
282
-				$this->backend->deleteCard($addressBookId, $cardId);
283
-			} else {
284
-				$this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
285
-			}
286
-		}
287
-	}
288
-
289
-	/**
290
-	 * @param IUser|string $userOrCardId
291
-	 */
292
-	public function deleteUser($userOrCardId) {
293
-		$systemAddressBook = $this->getLocalSystemAddressBook();
294
-		if ($userOrCardId instanceof IUser){
295
-			$name = $userOrCardId->getBackendClassName();
296
-			$userId = $userOrCardId->getUID();
297
-
298
-			$userOrCardId = "$name:$userId.vcf";
299
-		}
300
-		$this->backend->deleteCard($systemAddressBook['id'], $userOrCardId);
301
-	}
302
-
303
-	/**
304
-	 * @return array|null
305
-	 */
306
-	public function getLocalSystemAddressBook() {
307
-		if (is_null($this->localSystemAddressBook)) {
308
-			$systemPrincipal = "principals/system/system";
309
-			$this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [
310
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
311
-			]);
312
-		}
313
-
314
-		return $this->localSystemAddressBook;
315
-	}
316
-
317
-	public function syncInstance(\Closure $progressCallback = null) {
318
-		$systemAddressBook = $this->getLocalSystemAddressBook();
319
-		$this->userManager->callForAllUsers(function($user) use ($systemAddressBook, $progressCallback) {
320
-			$this->updateUser($user);
321
-			if (!is_null($progressCallback)) {
322
-				$progressCallback();
323
-			}
324
-		});
325
-
326
-		// remove no longer existing
327
-		$allCards = $this->backend->getCards($systemAddressBook['id']);
328
-		foreach($allCards as $card) {
329
-			$vCard = Reader::read($card['carddata']);
330
-			$uid = $vCard->UID->getValue();
331
-			// load backend and see if user exists
332
-			if (!$this->userManager->userExists($uid)) {
333
-				$this->deleteUser($card['uri']);
334
-			}
335
-		}
336
-	}
41
+    /** @var CardDavBackend */
42
+    private $backend;
43
+
44
+    /** @var IUserManager */
45
+    private $userManager;
46
+
47
+    /** @var ILogger */
48
+    private $logger;
49
+
50
+    /** @var array */
51
+    private $localSystemAddressBook;
52
+
53
+    /** @var AccountManager */
54
+    private $accountManager;
55
+
56
+    /** @var string */
57
+    protected $certPath;
58
+
59
+    /**
60
+     * SyncService constructor.
61
+     *
62
+     * @param CardDavBackend $backend
63
+     * @param IUserManager $userManager
64
+     * @param ILogger $logger
65
+     * @param AccountManager $accountManager
66
+     */
67
+    public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) {
68
+        $this->backend = $backend;
69
+        $this->userManager = $userManager;
70
+        $this->logger = $logger;
71
+        $this->accountManager = $accountManager;
72
+        $this->certPath = '';
73
+    }
74
+
75
+    /**
76
+     * @param string $url
77
+     * @param string $userName
78
+     * @param string $addressBookUrl
79
+     * @param string $sharedSecret
80
+     * @param string $syncToken
81
+     * @param int $targetBookId
82
+     * @param string $targetPrincipal
83
+     * @param array $targetProperties
84
+     * @return string
85
+     * @throws \Exception
86
+     */
87
+    public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
88
+        // 1. create addressbook
89
+        $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
90
+        $addressBookId = $book['id'];
91
+
92
+        // 2. query changes
93
+        try {
94
+            $response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken);
95
+        } catch (ClientHttpException $ex) {
96
+            if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
97
+                // remote server revoked access to the address book, remove it
98
+                $this->backend->deleteAddressBook($addressBookId);
99
+                $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']);
100
+                throw $ex;
101
+            }
102
+        }
103
+
104
+        // 3. apply changes
105
+        // TODO: use multi-get for download
106
+        foreach ($response['response'] as $resource => $status) {
107
+            $cardUri = basename($resource);
108
+            if (isset($status[200])) {
109
+                $vCard = $this->download($url, $userName, $sharedSecret, $resource);
110
+                $existingCard = $this->backend->getCard($addressBookId, $cardUri);
111
+                if ($existingCard === false) {
112
+                    $this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
113
+                } else {
114
+                    $this->backend->updateCard($addressBookId, $cardUri, $vCard['body']);
115
+                }
116
+            } else {
117
+                $this->backend->deleteCard($addressBookId, $cardUri);
118
+            }
119
+        }
120
+
121
+        return $response['token'];
122
+    }
123
+
124
+    /**
125
+     * @param string $principal
126
+     * @param string $id
127
+     * @param array $properties
128
+     * @return array|null
129
+     * @throws \Sabre\DAV\Exception\BadRequest
130
+     */
131
+    public function ensureSystemAddressBookExists($principal, $id, $properties) {
132
+        $book = $this->backend->getAddressBooksByUri($principal, $id);
133
+        if (!is_null($book)) {
134
+            return $book;
135
+        }
136
+        $this->backend->createAddressBook($principal, $id, $properties);
137
+
138
+        return $this->backend->getAddressBooksByUri($principal, $id);
139
+    }
140
+
141
+    /**
142
+     * Check if there is a valid certPath we should use
143
+     *
144
+     * @return string
145
+     */
146
+    protected function getCertPath() {
147
+
148
+        // we already have a valid certPath
149
+        if ($this->certPath !== '') {
150
+            return $this->certPath;
151
+        }
152
+
153
+        /** @var ICertificateManager $certManager */
154
+        $certManager = \OC::$server->getCertificateManager(null);
155
+        $certPath = $certManager->getAbsoluteBundlePath();
156
+        if (file_exists($certPath)) {
157
+            $this->certPath = $certPath;
158
+        }
159
+
160
+        return $this->certPath;
161
+    }
162
+
163
+    /**
164
+     * @param string $url
165
+     * @param string $userName
166
+     * @param string $addressBookUrl
167
+     * @param string $sharedSecret
168
+     * @return Client
169
+     */
170
+    protected function getClient($url, $userName, $sharedSecret) {
171
+        $settings = [
172
+            'baseUri' => $url . '/',
173
+            'userName' => $userName,
174
+            'password' => $sharedSecret,
175
+        ];
176
+        $client = new Client($settings);
177
+        $certPath = $this->getCertPath();
178
+        $client->setThrowExceptions(true);
179
+
180
+        if ($certPath !== '' && strpos($url, 'http://') !== 0) {
181
+            $client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
182
+        }
183
+
184
+        return $client;
185
+    }
186
+
187
+    /**
188
+     * @param string $url
189
+     * @param string $userName
190
+     * @param string $addressBookUrl
191
+     * @param string $sharedSecret
192
+     * @param string $syncToken
193
+     * @return array
194
+     */
195
+        protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
196
+            $client = $this->getClient($url, $userName, $sharedSecret);
197
+
198
+            $body = $this->buildSyncCollectionRequestBody($syncToken);
199
+
200
+            $response = $client->request('REPORT', $addressBookUrl, $body, [
201
+                'Content-Type' => 'application/xml'
202
+            ]);
203
+
204
+            return $this->parseMultiStatus($response['body']);
205
+        }
206
+
207
+    /**
208
+     * @param string $url
209
+     * @param string $userName
210
+     * @param string $sharedSecret
211
+     * @param string $resourcePath
212
+     * @return array
213
+     */
214
+    protected function download($url, $userName, $sharedSecret, $resourcePath) {
215
+        $client = $this->getClient($url, $userName, $sharedSecret);
216
+        return $client->request('GET', $resourcePath);
217
+    }
218
+
219
+    /**
220
+     * @param string|null $syncToken
221
+     * @return string
222
+     */
223
+    private function buildSyncCollectionRequestBody($syncToken) {
224
+
225
+        $dom = new \DOMDocument('1.0', 'UTF-8');
226
+        $dom->formatOutput = true;
227
+        $root = $dom->createElementNS('DAV:', 'd:sync-collection');
228
+        $sync = $dom->createElement('d:sync-token', $syncToken);
229
+        $prop = $dom->createElement('d:prop');
230
+        $cont = $dom->createElement('d:getcontenttype');
231
+        $etag = $dom->createElement('d:getetag');
232
+
233
+        $prop->appendChild($cont);
234
+        $prop->appendChild($etag);
235
+        $root->appendChild($sync);
236
+        $root->appendChild($prop);
237
+        $dom->appendChild($root);
238
+        $body = $dom->saveXML();
239
+
240
+        return $body;
241
+    }
242
+
243
+    /**
244
+     * @param string $body
245
+     * @return array
246
+     * @throws \Sabre\Xml\ParseException
247
+     */
248
+    private function parseMultiStatus($body) {
249
+        $xml = new Service();
250
+
251
+        /** @var MultiStatus $multiStatus */
252
+        $multiStatus = $xml->expect('{DAV:}multistatus', $body);
253
+
254
+        $result = [];
255
+        foreach ($multiStatus->getResponses() as $response) {
256
+            $result[$response->getHref()] = $response->getResponseProperties();
257
+        }
258
+
259
+        return ['response' => $result, 'token' => $multiStatus->getSyncToken()];
260
+    }
261
+
262
+    /**
263
+     * @param IUser $user
264
+     */
265
+    public function updateUser($user) {
266
+        $systemAddressBook = $this->getLocalSystemAddressBook();
267
+        $addressBookId = $systemAddressBook['id'];
268
+        $converter = new Converter($this->accountManager);
269
+        $name = $user->getBackendClassName();
270
+        $userId = $user->getUID();
271
+
272
+        $cardId = "$name:$userId.vcf";
273
+        $card = $this->backend->getCard($addressBookId, $cardId);
274
+        if ($card === false) {
275
+            $vCard = $converter->createCardFromUser($user);
276
+            if ($vCard !== null) {
277
+                $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
278
+            }
279
+        } else {
280
+            $vCard = $converter->createCardFromUser($user);
281
+            if (is_null($vCard)) {
282
+                $this->backend->deleteCard($addressBookId, $cardId);
283
+            } else {
284
+                $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
285
+            }
286
+        }
287
+    }
288
+
289
+    /**
290
+     * @param IUser|string $userOrCardId
291
+     */
292
+    public function deleteUser($userOrCardId) {
293
+        $systemAddressBook = $this->getLocalSystemAddressBook();
294
+        if ($userOrCardId instanceof IUser){
295
+            $name = $userOrCardId->getBackendClassName();
296
+            $userId = $userOrCardId->getUID();
297
+
298
+            $userOrCardId = "$name:$userId.vcf";
299
+        }
300
+        $this->backend->deleteCard($systemAddressBook['id'], $userOrCardId);
301
+    }
302
+
303
+    /**
304
+     * @return array|null
305
+     */
306
+    public function getLocalSystemAddressBook() {
307
+        if (is_null($this->localSystemAddressBook)) {
308
+            $systemPrincipal = "principals/system/system";
309
+            $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [
310
+                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
311
+            ]);
312
+        }
313
+
314
+        return $this->localSystemAddressBook;
315
+    }
316
+
317
+    public function syncInstance(\Closure $progressCallback = null) {
318
+        $systemAddressBook = $this->getLocalSystemAddressBook();
319
+        $this->userManager->callForAllUsers(function($user) use ($systemAddressBook, $progressCallback) {
320
+            $this->updateUser($user);
321
+            if (!is_null($progressCallback)) {
322
+                $progressCallback();
323
+            }
324
+        });
325
+
326
+        // remove no longer existing
327
+        $allCards = $this->backend->getCards($systemAddressBook['id']);
328
+        foreach($allCards as $card) {
329
+            $vCard = Reader::read($card['carddata']);
330
+            $uid = $vCard->UID->getValue();
331
+            // load backend and see if user exists
332
+            if (!$this->userManager->userExists($uid)) {
333
+                $this->deleteUser($card['uri']);
334
+            }
335
+        }
336
+    }
337 337
 
338 338
 
339 339
 }
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Indentation   +1591 added lines, -1591 removed lines patch added patch discarded remove patch
@@ -116,1600 +116,1600 @@
 block discarded – undo
116 116
  * TODO: hookup all manager classes
117 117
  */
118 118
 class Server extends ServerContainer implements IServerContainer {
119
-	/** @var string */
120
-	private $webRoot;
121
-
122
-	/**
123
-	 * @param string $webRoot
124
-	 * @param \OC\Config $config
125
-	 */
126
-	public function __construct($webRoot, \OC\Config $config) {
127
-		parent::__construct();
128
-		$this->webRoot = $webRoot;
129
-
130
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
131
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
132
-
133
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
134
-			return new PreviewManager(
135
-				$c->getConfig(),
136
-				$c->getRootFolder(),
137
-				$c->getAppDataDir('preview'),
138
-				$c->getEventDispatcher(),
139
-				$c->getSession()->get('user_id')
140
-			);
141
-		});
142
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
143
-
144
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
145
-			return new \OC\Preview\Watcher(
146
-				$c->getAppDataDir('preview')
147
-			);
148
-		});
149
-
150
-		$this->registerService('EncryptionManager', function (Server $c) {
151
-			$view = new View();
152
-			$util = new Encryption\Util(
153
-				$view,
154
-				$c->getUserManager(),
155
-				$c->getGroupManager(),
156
-				$c->getConfig()
157
-			);
158
-			return new Encryption\Manager(
159
-				$c->getConfig(),
160
-				$c->getLogger(),
161
-				$c->getL10N('core'),
162
-				new View(),
163
-				$util,
164
-				new ArrayCache()
165
-			);
166
-		});
167
-
168
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
169
-			$util = new Encryption\Util(
170
-				new View(),
171
-				$c->getUserManager(),
172
-				$c->getGroupManager(),
173
-				$c->getConfig()
174
-			);
175
-			return new Encryption\File($util);
176
-		});
177
-
178
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
179
-			$view = new View();
180
-			$util = new Encryption\Util(
181
-				$view,
182
-				$c->getUserManager(),
183
-				$c->getGroupManager(),
184
-				$c->getConfig()
185
-			);
186
-
187
-			return new Encryption\Keys\Storage($view, $util);
188
-		});
189
-		$this->registerService('TagMapper', function (Server $c) {
190
-			return new TagMapper($c->getDatabaseConnection());
191
-		});
192
-
193
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
194
-			$tagMapper = $c->query('TagMapper');
195
-			return new TagManager($tagMapper, $c->getUserSession());
196
-		});
197
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
198
-
199
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
200
-			$config = $c->getConfig();
201
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
202
-			/** @var \OC\SystemTag\ManagerFactory $factory */
203
-			$factory = new $factoryClass($this);
204
-			return $factory;
205
-		});
206
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
207
-			return $c->query('SystemTagManagerFactory')->getManager();
208
-		});
209
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
210
-
211
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
212
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
213
-		});
214
-		$this->registerService('RootFolder', function (Server $c) {
215
-			$manager = \OC\Files\Filesystem::getMountManager(null);
216
-			$view = new View();
217
-			$root = new Root(
218
-				$manager,
219
-				$view,
220
-				null,
221
-				$c->getUserMountCache(),
222
-				$this->getLogger(),
223
-				$this->getUserManager()
224
-			);
225
-			$connector = new HookConnector($root, $view);
226
-			$connector->viewToNode();
227
-
228
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
229
-			$previewConnector->connectWatcher();
230
-
231
-			return $root;
232
-		});
233
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
234
-
235
-		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
236
-			return new LazyRoot(function() use ($c) {
237
-				return $c->query('RootFolder');
238
-			});
239
-		});
240
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
241
-
242
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
243
-			$config = $c->getConfig();
244
-			return new \OC\User\Manager($config);
245
-		});
246
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
247
-
248
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
249
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
250
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
251
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
252
-			});
253
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
254
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
255
-			});
256
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
257
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
258
-			});
259
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
260
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
261
-			});
262
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
263
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
264
-			});
265
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
266
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
267
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
268
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
269
-			});
270
-			return $groupManager;
271
-		});
272
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
273
-
274
-		$this->registerService(Store::class, function(Server $c) {
275
-			$session = $c->getSession();
276
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
277
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
278
-			} else {
279
-				$tokenProvider = null;
280
-			}
281
-			$logger = $c->getLogger();
282
-			return new Store($session, $logger, $tokenProvider);
283
-		});
284
-		$this->registerAlias(IStore::class, Store::class);
285
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
286
-			$dbConnection = $c->getDatabaseConnection();
287
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
288
-		});
289
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
290
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
291
-			$crypto = $c->getCrypto();
292
-			$config = $c->getConfig();
293
-			$logger = $c->getLogger();
294
-			$timeFactory = new TimeFactory();
295
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
296
-		});
297
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
298
-
299
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
300
-			$manager = $c->getUserManager();
301
-			$session = new \OC\Session\Memory('');
302
-			$timeFactory = new TimeFactory();
303
-			// Token providers might require a working database. This code
304
-			// might however be called when ownCloud is not yet setup.
305
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
306
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
307
-			} else {
308
-				$defaultTokenProvider = null;
309
-			}
310
-
311
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
312
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
313
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
314
-			});
315
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
316
-				/** @var $user \OC\User\User */
317
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
318
-			});
319
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
320
-				/** @var $user \OC\User\User */
321
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
322
-			});
323
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
324
-				/** @var $user \OC\User\User */
325
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
326
-			});
327
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
328
-				/** @var $user \OC\User\User */
329
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
330
-			});
331
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
332
-				/** @var $user \OC\User\User */
333
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
334
-			});
335
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
336
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
337
-			});
338
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
339
-				/** @var $user \OC\User\User */
340
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
341
-			});
342
-			$userSession->listen('\OC\User', 'logout', function () {
343
-				\OC_Hook::emit('OC_User', 'logout', array());
344
-			});
345
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
346
-				/** @var $user \OC\User\User */
347
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
348
-			});
349
-			return $userSession;
350
-		});
351
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
352
-
353
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
354
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
355
-		});
356
-
357
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
358
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
359
-
360
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
361
-			return new \OC\AllConfig(
362
-				$c->getSystemConfig()
363
-			);
364
-		});
365
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
366
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
367
-
368
-		$this->registerService('SystemConfig', function ($c) use ($config) {
369
-			return new \OC\SystemConfig($config);
370
-		});
371
-
372
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
373
-			return new \OC\AppConfig($c->getDatabaseConnection());
374
-		});
375
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
376
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
377
-
378
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
379
-			return new \OC\L10N\Factory(
380
-				$c->getConfig(),
381
-				$c->getRequest(),
382
-				$c->getUserSession(),
383
-				\OC::$SERVERROOT
384
-			);
385
-		});
386
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
387
-
388
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
389
-			$config = $c->getConfig();
390
-			$cacheFactory = $c->getMemCacheFactory();
391
-			return new \OC\URLGenerator(
392
-				$config,
393
-				$cacheFactory
394
-			);
395
-		});
396
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
397
-
398
-		$this->registerService('AppHelper', function ($c) {
399
-			return new \OC\AppHelper();
400
-		});
401
-		$this->registerService('AppFetcher', function ($c) {
402
-			return new AppFetcher(
403
-				$this->getAppDataDir('appstore'),
404
-				$this->getHTTPClientService(),
405
-				$this->query(TimeFactory::class),
406
-				$this->getConfig()
407
-			);
408
-		});
409
-		$this->registerService('CategoryFetcher', function ($c) {
410
-			return new CategoryFetcher(
411
-				$this->getAppDataDir('appstore'),
412
-				$this->getHTTPClientService(),
413
-				$this->query(TimeFactory::class),
414
-				$this->getConfig()
415
-			);
416
-		});
417
-
418
-		$this->registerService(\OCP\ICache::class, function ($c) {
419
-			return new Cache\File();
420
-		});
421
-		$this->registerAlias('UserCache', \OCP\ICache::class);
422
-
423
-		$this->registerService(Factory::class, function (Server $c) {
424
-			$config = $c->getConfig();
425
-
426
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
427
-				$v = \OC_App::getAppVersions();
428
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
429
-				$version = implode(',', $v);
430
-				$instanceId = \OC_Util::getInstanceId();
431
-				$path = \OC::$SERVERROOT;
432
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
433
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
434
-					$config->getSystemValue('memcache.local', null),
435
-					$config->getSystemValue('memcache.distributed', null),
436
-					$config->getSystemValue('memcache.locking', null)
437
-				);
438
-			}
439
-
440
-			return new \OC\Memcache\Factory('', $c->getLogger(),
441
-				'\\OC\\Memcache\\ArrayCache',
442
-				'\\OC\\Memcache\\ArrayCache',
443
-				'\\OC\\Memcache\\ArrayCache'
444
-			);
445
-		});
446
-		$this->registerAlias('MemCacheFactory', Factory::class);
447
-		$this->registerAlias(ICacheFactory::class, Factory::class);
448
-
449
-		$this->registerService('RedisFactory', function (Server $c) {
450
-			$systemConfig = $c->getSystemConfig();
451
-			return new RedisFactory($systemConfig);
452
-		});
453
-
454
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
455
-			return new \OC\Activity\Manager(
456
-				$c->getRequest(),
457
-				$c->getUserSession(),
458
-				$c->getConfig(),
459
-				$c->query(IValidator::class)
460
-			);
461
-		});
462
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
463
-
464
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
465
-			return new \OC\Activity\EventMerger(
466
-				$c->getL10N('lib')
467
-			);
468
-		});
469
-		$this->registerAlias(IValidator::class, Validator::class);
470
-
471
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
472
-			return new AvatarManager(
473
-				$c->getUserManager(),
474
-				$c->getAppDataDir('avatar'),
475
-				$c->getL10N('lib'),
476
-				$c->getLogger(),
477
-				$c->getConfig()
478
-			);
479
-		});
480
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
481
-
482
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
483
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
484
-			$logger = Log::getLogClass($logType);
485
-			call_user_func(array($logger, 'init'));
486
-
487
-			return new Log($logger);
488
-		});
489
-		$this->registerAlias('Logger', \OCP\ILogger::class);
490
-
491
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
492
-			$config = $c->getConfig();
493
-			return new \OC\BackgroundJob\JobList(
494
-				$c->getDatabaseConnection(),
495
-				$config,
496
-				new TimeFactory()
497
-			);
498
-		});
499
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
500
-
501
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
502
-			$cacheFactory = $c->getMemCacheFactory();
503
-			$logger = $c->getLogger();
504
-			if ($cacheFactory->isAvailable()) {
505
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
506
-			} else {
507
-				$router = new \OC\Route\Router($logger);
508
-			}
509
-			return $router;
510
-		});
511
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
512
-
513
-		$this->registerService(\OCP\ISearch::class, function ($c) {
514
-			return new Search();
515
-		});
516
-		$this->registerAlias('Search', \OCP\ISearch::class);
517
-
518
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
519
-			return new SecureRandom();
520
-		});
521
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
522
-
523
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
524
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
525
-		});
526
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
527
-
528
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
529
-			return new Hasher($c->getConfig());
530
-		});
531
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
532
-
533
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
534
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
535
-		});
536
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
537
-
538
-		$this->registerService(IDBConnection::class, function (Server $c) {
539
-			$systemConfig = $c->getSystemConfig();
540
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
541
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
542
-			if (!$factory->isValidType($type)) {
543
-				throw new \OC\DatabaseException('Invalid database type');
544
-			}
545
-			$connectionParams = $factory->createConnectionParams();
546
-			$connection = $factory->getConnection($type, $connectionParams);
547
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
548
-			return $connection;
549
-		});
550
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
551
-
552
-		$this->registerService('HTTPHelper', function (Server $c) {
553
-			$config = $c->getConfig();
554
-			return new HTTPHelper(
555
-				$config,
556
-				$c->getHTTPClientService()
557
-			);
558
-		});
559
-
560
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
561
-			$user = \OC_User::getUser();
562
-			$uid = $user ? $user : null;
563
-			return new ClientService(
564
-				$c->getConfig(),
565
-				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
566
-			);
567
-		});
568
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
569
-
570
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
571
-			if ($c->getSystemConfig()->getValue('debug', false)) {
572
-				return new EventLogger();
573
-			} else {
574
-				return new NullEventLogger();
575
-			}
576
-		});
577
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
578
-
579
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
580
-			if ($c->getSystemConfig()->getValue('debug', false)) {
581
-				return new QueryLogger();
582
-			} else {
583
-				return new NullQueryLogger();
584
-			}
585
-		});
586
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
587
-
588
-		$this->registerService(TempManager::class, function (Server $c) {
589
-			return new TempManager(
590
-				$c->getLogger(),
591
-				$c->getConfig()
592
-			);
593
-		});
594
-		$this->registerAlias('TempManager', TempManager::class);
595
-		$this->registerAlias(ITempManager::class, TempManager::class);
596
-
597
-		$this->registerService(AppManager::class, function (Server $c) {
598
-			return new \OC\App\AppManager(
599
-				$c->getUserSession(),
600
-				$c->getAppConfig(),
601
-				$c->getGroupManager(),
602
-				$c->getMemCacheFactory(),
603
-				$c->getEventDispatcher()
604
-			);
605
-		});
606
-		$this->registerAlias('AppManager', AppManager::class);
607
-		$this->registerAlias(IAppManager::class, AppManager::class);
608
-
609
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
610
-			return new DateTimeZone(
611
-				$c->getConfig(),
612
-				$c->getSession()
613
-			);
614
-		});
615
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
616
-
617
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
618
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
619
-
620
-			return new DateTimeFormatter(
621
-				$c->getDateTimeZone()->getTimeZone(),
622
-				$c->getL10N('lib', $language)
623
-			);
624
-		});
625
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
626
-
627
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
628
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
629
-			$listener = new UserMountCacheListener($mountCache);
630
-			$listener->listen($c->getUserManager());
631
-			return $mountCache;
632
-		});
633
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
634
-
635
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
636
-			$loader = \OC\Files\Filesystem::getLoader();
637
-			$mountCache = $c->query('UserMountCache');
638
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
639
-
640
-			// builtin providers
641
-
642
-			$config = $c->getConfig();
643
-			$manager->registerProvider(new CacheMountProvider($config));
644
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
645
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
646
-
647
-			return $manager;
648
-		});
649
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
650
-
651
-		$this->registerService('IniWrapper', function ($c) {
652
-			return new IniGetWrapper();
653
-		});
654
-		$this->registerService('AsyncCommandBus', function (Server $c) {
655
-			$jobList = $c->getJobList();
656
-			return new AsyncBus($jobList);
657
-		});
658
-		$this->registerService('TrustedDomainHelper', function ($c) {
659
-			return new TrustedDomainHelper($this->getConfig());
660
-		});
661
-		$this->registerService('Throttler', function(Server $c) {
662
-			return new Throttler(
663
-				$c->getDatabaseConnection(),
664
-				new TimeFactory(),
665
-				$c->getLogger(),
666
-				$c->getConfig()
667
-			);
668
-		});
669
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
670
-			// IConfig and IAppManager requires a working database. This code
671
-			// might however be called when ownCloud is not yet setup.
672
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
673
-				$config = $c->getConfig();
674
-				$appManager = $c->getAppManager();
675
-			} else {
676
-				$config = null;
677
-				$appManager = null;
678
-			}
679
-
680
-			return new Checker(
681
-					new EnvironmentHelper(),
682
-					new FileAccessHelper(),
683
-					new AppLocator(),
684
-					$config,
685
-					$c->getMemCacheFactory(),
686
-					$appManager,
687
-					$c->getTempManager()
688
-			);
689
-		});
690
-		$this->registerService(\OCP\IRequest::class, function ($c) {
691
-			if (isset($this['urlParams'])) {
692
-				$urlParams = $this['urlParams'];
693
-			} else {
694
-				$urlParams = [];
695
-			}
696
-
697
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
698
-				&& in_array('fakeinput', stream_get_wrappers())
699
-			) {
700
-				$stream = 'fakeinput://data';
701
-			} else {
702
-				$stream = 'php://input';
703
-			}
704
-
705
-			return new Request(
706
-				[
707
-					'get' => $_GET,
708
-					'post' => $_POST,
709
-					'files' => $_FILES,
710
-					'server' => $_SERVER,
711
-					'env' => $_ENV,
712
-					'cookies' => $_COOKIE,
713
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
714
-						? $_SERVER['REQUEST_METHOD']
715
-						: null,
716
-					'urlParams' => $urlParams,
717
-				],
718
-				$this->getSecureRandom(),
719
-				$this->getConfig(),
720
-				$this->getCsrfTokenManager(),
721
-				$stream
722
-			);
723
-		});
724
-		$this->registerAlias('Request', \OCP\IRequest::class);
725
-
726
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
727
-			return new Mailer(
728
-				$c->getConfig(),
729
-				$c->getLogger(),
730
-				$c->getThemingDefaults()
731
-			);
732
-		});
733
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
734
-
735
-		$this->registerService('LDAPProvider', function(Server $c) {
736
-			$config = $c->getConfig();
737
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
738
-			if(is_null($factoryClass)) {
739
-				throw new \Exception('ldapProviderFactory not set');
740
-			}
741
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
742
-			$factory = new $factoryClass($this);
743
-			return $factory->getLDAPProvider();
744
-		});
745
-		$this->registerService('LockingProvider', function (Server $c) {
746
-			$ini = $c->getIniWrapper();
747
-			$config = $c->getConfig();
748
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
749
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
750
-				/** @var \OC\Memcache\Factory $memcacheFactory */
751
-				$memcacheFactory = $c->getMemCacheFactory();
752
-				$memcache = $memcacheFactory->createLocking('lock');
753
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
754
-					return new MemcacheLockingProvider($memcache, $ttl);
755
-				}
756
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
757
-			}
758
-			return new NoopLockingProvider();
759
-		});
760
-
761
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
762
-			return new \OC\Files\Mount\Manager();
763
-		});
764
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
765
-
766
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
767
-			return new \OC\Files\Type\Detection(
768
-				$c->getURLGenerator(),
769
-				\OC::$configDir,
770
-				\OC::$SERVERROOT . '/resources/config/'
771
-			);
772
-		});
773
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
774
-
775
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
776
-			return new \OC\Files\Type\Loader(
777
-				$c->getDatabaseConnection()
778
-			);
779
-		});
780
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
781
-
782
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
783
-			return new Manager(
784
-				$c->query(IValidator::class)
785
-			);
786
-		});
787
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
788
-
789
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
790
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
791
-			$manager->registerCapability(function () use ($c) {
792
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
793
-			});
794
-			return $manager;
795
-		});
796
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
797
-
798
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
799
-			$config = $c->getConfig();
800
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
801
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
802
-			$factory = new $factoryClass($this);
803
-			return $factory->getManager();
804
-		});
805
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
806
-
807
-		$this->registerService('ThemingDefaults', function(Server $c) {
808
-			/*
119
+    /** @var string */
120
+    private $webRoot;
121
+
122
+    /**
123
+     * @param string $webRoot
124
+     * @param \OC\Config $config
125
+     */
126
+    public function __construct($webRoot, \OC\Config $config) {
127
+        parent::__construct();
128
+        $this->webRoot = $webRoot;
129
+
130
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
131
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
132
+
133
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
134
+            return new PreviewManager(
135
+                $c->getConfig(),
136
+                $c->getRootFolder(),
137
+                $c->getAppDataDir('preview'),
138
+                $c->getEventDispatcher(),
139
+                $c->getSession()->get('user_id')
140
+            );
141
+        });
142
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
143
+
144
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
145
+            return new \OC\Preview\Watcher(
146
+                $c->getAppDataDir('preview')
147
+            );
148
+        });
149
+
150
+        $this->registerService('EncryptionManager', function (Server $c) {
151
+            $view = new View();
152
+            $util = new Encryption\Util(
153
+                $view,
154
+                $c->getUserManager(),
155
+                $c->getGroupManager(),
156
+                $c->getConfig()
157
+            );
158
+            return new Encryption\Manager(
159
+                $c->getConfig(),
160
+                $c->getLogger(),
161
+                $c->getL10N('core'),
162
+                new View(),
163
+                $util,
164
+                new ArrayCache()
165
+            );
166
+        });
167
+
168
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
169
+            $util = new Encryption\Util(
170
+                new View(),
171
+                $c->getUserManager(),
172
+                $c->getGroupManager(),
173
+                $c->getConfig()
174
+            );
175
+            return new Encryption\File($util);
176
+        });
177
+
178
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
179
+            $view = new View();
180
+            $util = new Encryption\Util(
181
+                $view,
182
+                $c->getUserManager(),
183
+                $c->getGroupManager(),
184
+                $c->getConfig()
185
+            );
186
+
187
+            return new Encryption\Keys\Storage($view, $util);
188
+        });
189
+        $this->registerService('TagMapper', function (Server $c) {
190
+            return new TagMapper($c->getDatabaseConnection());
191
+        });
192
+
193
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
194
+            $tagMapper = $c->query('TagMapper');
195
+            return new TagManager($tagMapper, $c->getUserSession());
196
+        });
197
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
198
+
199
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
200
+            $config = $c->getConfig();
201
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
202
+            /** @var \OC\SystemTag\ManagerFactory $factory */
203
+            $factory = new $factoryClass($this);
204
+            return $factory;
205
+        });
206
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
207
+            return $c->query('SystemTagManagerFactory')->getManager();
208
+        });
209
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
210
+
211
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
212
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
213
+        });
214
+        $this->registerService('RootFolder', function (Server $c) {
215
+            $manager = \OC\Files\Filesystem::getMountManager(null);
216
+            $view = new View();
217
+            $root = new Root(
218
+                $manager,
219
+                $view,
220
+                null,
221
+                $c->getUserMountCache(),
222
+                $this->getLogger(),
223
+                $this->getUserManager()
224
+            );
225
+            $connector = new HookConnector($root, $view);
226
+            $connector->viewToNode();
227
+
228
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
229
+            $previewConnector->connectWatcher();
230
+
231
+            return $root;
232
+        });
233
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
234
+
235
+        $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
236
+            return new LazyRoot(function() use ($c) {
237
+                return $c->query('RootFolder');
238
+            });
239
+        });
240
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
241
+
242
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
243
+            $config = $c->getConfig();
244
+            return new \OC\User\Manager($config);
245
+        });
246
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
247
+
248
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
249
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
250
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
251
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
252
+            });
253
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
254
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
255
+            });
256
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
257
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
258
+            });
259
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
260
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
261
+            });
262
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
263
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
264
+            });
265
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
266
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
267
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
268
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
269
+            });
270
+            return $groupManager;
271
+        });
272
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
273
+
274
+        $this->registerService(Store::class, function(Server $c) {
275
+            $session = $c->getSession();
276
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
277
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
278
+            } else {
279
+                $tokenProvider = null;
280
+            }
281
+            $logger = $c->getLogger();
282
+            return new Store($session, $logger, $tokenProvider);
283
+        });
284
+        $this->registerAlias(IStore::class, Store::class);
285
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
286
+            $dbConnection = $c->getDatabaseConnection();
287
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
288
+        });
289
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
290
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
291
+            $crypto = $c->getCrypto();
292
+            $config = $c->getConfig();
293
+            $logger = $c->getLogger();
294
+            $timeFactory = new TimeFactory();
295
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
296
+        });
297
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
298
+
299
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
300
+            $manager = $c->getUserManager();
301
+            $session = new \OC\Session\Memory('');
302
+            $timeFactory = new TimeFactory();
303
+            // Token providers might require a working database. This code
304
+            // might however be called when ownCloud is not yet setup.
305
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
306
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
307
+            } else {
308
+                $defaultTokenProvider = null;
309
+            }
310
+
311
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
312
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
313
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
314
+            });
315
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
316
+                /** @var $user \OC\User\User */
317
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
318
+            });
319
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
320
+                /** @var $user \OC\User\User */
321
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
322
+            });
323
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
324
+                /** @var $user \OC\User\User */
325
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
326
+            });
327
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
328
+                /** @var $user \OC\User\User */
329
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
330
+            });
331
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
332
+                /** @var $user \OC\User\User */
333
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
334
+            });
335
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
336
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
337
+            });
338
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
339
+                /** @var $user \OC\User\User */
340
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
341
+            });
342
+            $userSession->listen('\OC\User', 'logout', function () {
343
+                \OC_Hook::emit('OC_User', 'logout', array());
344
+            });
345
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
346
+                /** @var $user \OC\User\User */
347
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
348
+            });
349
+            return $userSession;
350
+        });
351
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
352
+
353
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
354
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
355
+        });
356
+
357
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
358
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
359
+
360
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
361
+            return new \OC\AllConfig(
362
+                $c->getSystemConfig()
363
+            );
364
+        });
365
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
366
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
367
+
368
+        $this->registerService('SystemConfig', function ($c) use ($config) {
369
+            return new \OC\SystemConfig($config);
370
+        });
371
+
372
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
373
+            return new \OC\AppConfig($c->getDatabaseConnection());
374
+        });
375
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
376
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
377
+
378
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
379
+            return new \OC\L10N\Factory(
380
+                $c->getConfig(),
381
+                $c->getRequest(),
382
+                $c->getUserSession(),
383
+                \OC::$SERVERROOT
384
+            );
385
+        });
386
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
387
+
388
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
389
+            $config = $c->getConfig();
390
+            $cacheFactory = $c->getMemCacheFactory();
391
+            return new \OC\URLGenerator(
392
+                $config,
393
+                $cacheFactory
394
+            );
395
+        });
396
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
397
+
398
+        $this->registerService('AppHelper', function ($c) {
399
+            return new \OC\AppHelper();
400
+        });
401
+        $this->registerService('AppFetcher', function ($c) {
402
+            return new AppFetcher(
403
+                $this->getAppDataDir('appstore'),
404
+                $this->getHTTPClientService(),
405
+                $this->query(TimeFactory::class),
406
+                $this->getConfig()
407
+            );
408
+        });
409
+        $this->registerService('CategoryFetcher', function ($c) {
410
+            return new CategoryFetcher(
411
+                $this->getAppDataDir('appstore'),
412
+                $this->getHTTPClientService(),
413
+                $this->query(TimeFactory::class),
414
+                $this->getConfig()
415
+            );
416
+        });
417
+
418
+        $this->registerService(\OCP\ICache::class, function ($c) {
419
+            return new Cache\File();
420
+        });
421
+        $this->registerAlias('UserCache', \OCP\ICache::class);
422
+
423
+        $this->registerService(Factory::class, function (Server $c) {
424
+            $config = $c->getConfig();
425
+
426
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
427
+                $v = \OC_App::getAppVersions();
428
+                $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
429
+                $version = implode(',', $v);
430
+                $instanceId = \OC_Util::getInstanceId();
431
+                $path = \OC::$SERVERROOT;
432
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
433
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
434
+                    $config->getSystemValue('memcache.local', null),
435
+                    $config->getSystemValue('memcache.distributed', null),
436
+                    $config->getSystemValue('memcache.locking', null)
437
+                );
438
+            }
439
+
440
+            return new \OC\Memcache\Factory('', $c->getLogger(),
441
+                '\\OC\\Memcache\\ArrayCache',
442
+                '\\OC\\Memcache\\ArrayCache',
443
+                '\\OC\\Memcache\\ArrayCache'
444
+            );
445
+        });
446
+        $this->registerAlias('MemCacheFactory', Factory::class);
447
+        $this->registerAlias(ICacheFactory::class, Factory::class);
448
+
449
+        $this->registerService('RedisFactory', function (Server $c) {
450
+            $systemConfig = $c->getSystemConfig();
451
+            return new RedisFactory($systemConfig);
452
+        });
453
+
454
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
455
+            return new \OC\Activity\Manager(
456
+                $c->getRequest(),
457
+                $c->getUserSession(),
458
+                $c->getConfig(),
459
+                $c->query(IValidator::class)
460
+            );
461
+        });
462
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
463
+
464
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
465
+            return new \OC\Activity\EventMerger(
466
+                $c->getL10N('lib')
467
+            );
468
+        });
469
+        $this->registerAlias(IValidator::class, Validator::class);
470
+
471
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
472
+            return new AvatarManager(
473
+                $c->getUserManager(),
474
+                $c->getAppDataDir('avatar'),
475
+                $c->getL10N('lib'),
476
+                $c->getLogger(),
477
+                $c->getConfig()
478
+            );
479
+        });
480
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
481
+
482
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
483
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
484
+            $logger = Log::getLogClass($logType);
485
+            call_user_func(array($logger, 'init'));
486
+
487
+            return new Log($logger);
488
+        });
489
+        $this->registerAlias('Logger', \OCP\ILogger::class);
490
+
491
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
492
+            $config = $c->getConfig();
493
+            return new \OC\BackgroundJob\JobList(
494
+                $c->getDatabaseConnection(),
495
+                $config,
496
+                new TimeFactory()
497
+            );
498
+        });
499
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
500
+
501
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
502
+            $cacheFactory = $c->getMemCacheFactory();
503
+            $logger = $c->getLogger();
504
+            if ($cacheFactory->isAvailable()) {
505
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
506
+            } else {
507
+                $router = new \OC\Route\Router($logger);
508
+            }
509
+            return $router;
510
+        });
511
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
512
+
513
+        $this->registerService(\OCP\ISearch::class, function ($c) {
514
+            return new Search();
515
+        });
516
+        $this->registerAlias('Search', \OCP\ISearch::class);
517
+
518
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
519
+            return new SecureRandom();
520
+        });
521
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
522
+
523
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
524
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
525
+        });
526
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
527
+
528
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
529
+            return new Hasher($c->getConfig());
530
+        });
531
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
532
+
533
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
534
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
535
+        });
536
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
537
+
538
+        $this->registerService(IDBConnection::class, function (Server $c) {
539
+            $systemConfig = $c->getSystemConfig();
540
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
541
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
542
+            if (!$factory->isValidType($type)) {
543
+                throw new \OC\DatabaseException('Invalid database type');
544
+            }
545
+            $connectionParams = $factory->createConnectionParams();
546
+            $connection = $factory->getConnection($type, $connectionParams);
547
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
548
+            return $connection;
549
+        });
550
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
551
+
552
+        $this->registerService('HTTPHelper', function (Server $c) {
553
+            $config = $c->getConfig();
554
+            return new HTTPHelper(
555
+                $config,
556
+                $c->getHTTPClientService()
557
+            );
558
+        });
559
+
560
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
561
+            $user = \OC_User::getUser();
562
+            $uid = $user ? $user : null;
563
+            return new ClientService(
564
+                $c->getConfig(),
565
+                new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
566
+            );
567
+        });
568
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
569
+
570
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
571
+            if ($c->getSystemConfig()->getValue('debug', false)) {
572
+                return new EventLogger();
573
+            } else {
574
+                return new NullEventLogger();
575
+            }
576
+        });
577
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
578
+
579
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
580
+            if ($c->getSystemConfig()->getValue('debug', false)) {
581
+                return new QueryLogger();
582
+            } else {
583
+                return new NullQueryLogger();
584
+            }
585
+        });
586
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
587
+
588
+        $this->registerService(TempManager::class, function (Server $c) {
589
+            return new TempManager(
590
+                $c->getLogger(),
591
+                $c->getConfig()
592
+            );
593
+        });
594
+        $this->registerAlias('TempManager', TempManager::class);
595
+        $this->registerAlias(ITempManager::class, TempManager::class);
596
+
597
+        $this->registerService(AppManager::class, function (Server $c) {
598
+            return new \OC\App\AppManager(
599
+                $c->getUserSession(),
600
+                $c->getAppConfig(),
601
+                $c->getGroupManager(),
602
+                $c->getMemCacheFactory(),
603
+                $c->getEventDispatcher()
604
+            );
605
+        });
606
+        $this->registerAlias('AppManager', AppManager::class);
607
+        $this->registerAlias(IAppManager::class, AppManager::class);
608
+
609
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
610
+            return new DateTimeZone(
611
+                $c->getConfig(),
612
+                $c->getSession()
613
+            );
614
+        });
615
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
616
+
617
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
618
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
619
+
620
+            return new DateTimeFormatter(
621
+                $c->getDateTimeZone()->getTimeZone(),
622
+                $c->getL10N('lib', $language)
623
+            );
624
+        });
625
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
626
+
627
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
628
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
629
+            $listener = new UserMountCacheListener($mountCache);
630
+            $listener->listen($c->getUserManager());
631
+            return $mountCache;
632
+        });
633
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
634
+
635
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
636
+            $loader = \OC\Files\Filesystem::getLoader();
637
+            $mountCache = $c->query('UserMountCache');
638
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
639
+
640
+            // builtin providers
641
+
642
+            $config = $c->getConfig();
643
+            $manager->registerProvider(new CacheMountProvider($config));
644
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
645
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
646
+
647
+            return $manager;
648
+        });
649
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
650
+
651
+        $this->registerService('IniWrapper', function ($c) {
652
+            return new IniGetWrapper();
653
+        });
654
+        $this->registerService('AsyncCommandBus', function (Server $c) {
655
+            $jobList = $c->getJobList();
656
+            return new AsyncBus($jobList);
657
+        });
658
+        $this->registerService('TrustedDomainHelper', function ($c) {
659
+            return new TrustedDomainHelper($this->getConfig());
660
+        });
661
+        $this->registerService('Throttler', function(Server $c) {
662
+            return new Throttler(
663
+                $c->getDatabaseConnection(),
664
+                new TimeFactory(),
665
+                $c->getLogger(),
666
+                $c->getConfig()
667
+            );
668
+        });
669
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
670
+            // IConfig and IAppManager requires a working database. This code
671
+            // might however be called when ownCloud is not yet setup.
672
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
673
+                $config = $c->getConfig();
674
+                $appManager = $c->getAppManager();
675
+            } else {
676
+                $config = null;
677
+                $appManager = null;
678
+            }
679
+
680
+            return new Checker(
681
+                    new EnvironmentHelper(),
682
+                    new FileAccessHelper(),
683
+                    new AppLocator(),
684
+                    $config,
685
+                    $c->getMemCacheFactory(),
686
+                    $appManager,
687
+                    $c->getTempManager()
688
+            );
689
+        });
690
+        $this->registerService(\OCP\IRequest::class, function ($c) {
691
+            if (isset($this['urlParams'])) {
692
+                $urlParams = $this['urlParams'];
693
+            } else {
694
+                $urlParams = [];
695
+            }
696
+
697
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
698
+                && in_array('fakeinput', stream_get_wrappers())
699
+            ) {
700
+                $stream = 'fakeinput://data';
701
+            } else {
702
+                $stream = 'php://input';
703
+            }
704
+
705
+            return new Request(
706
+                [
707
+                    'get' => $_GET,
708
+                    'post' => $_POST,
709
+                    'files' => $_FILES,
710
+                    'server' => $_SERVER,
711
+                    'env' => $_ENV,
712
+                    'cookies' => $_COOKIE,
713
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
714
+                        ? $_SERVER['REQUEST_METHOD']
715
+                        : null,
716
+                    'urlParams' => $urlParams,
717
+                ],
718
+                $this->getSecureRandom(),
719
+                $this->getConfig(),
720
+                $this->getCsrfTokenManager(),
721
+                $stream
722
+            );
723
+        });
724
+        $this->registerAlias('Request', \OCP\IRequest::class);
725
+
726
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
727
+            return new Mailer(
728
+                $c->getConfig(),
729
+                $c->getLogger(),
730
+                $c->getThemingDefaults()
731
+            );
732
+        });
733
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
734
+
735
+        $this->registerService('LDAPProvider', function(Server $c) {
736
+            $config = $c->getConfig();
737
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
738
+            if(is_null($factoryClass)) {
739
+                throw new \Exception('ldapProviderFactory not set');
740
+            }
741
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
742
+            $factory = new $factoryClass($this);
743
+            return $factory->getLDAPProvider();
744
+        });
745
+        $this->registerService('LockingProvider', function (Server $c) {
746
+            $ini = $c->getIniWrapper();
747
+            $config = $c->getConfig();
748
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
749
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
750
+                /** @var \OC\Memcache\Factory $memcacheFactory */
751
+                $memcacheFactory = $c->getMemCacheFactory();
752
+                $memcache = $memcacheFactory->createLocking('lock');
753
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
754
+                    return new MemcacheLockingProvider($memcache, $ttl);
755
+                }
756
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
757
+            }
758
+            return new NoopLockingProvider();
759
+        });
760
+
761
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
762
+            return new \OC\Files\Mount\Manager();
763
+        });
764
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
765
+
766
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
767
+            return new \OC\Files\Type\Detection(
768
+                $c->getURLGenerator(),
769
+                \OC::$configDir,
770
+                \OC::$SERVERROOT . '/resources/config/'
771
+            );
772
+        });
773
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
774
+
775
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
776
+            return new \OC\Files\Type\Loader(
777
+                $c->getDatabaseConnection()
778
+            );
779
+        });
780
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
781
+
782
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
783
+            return new Manager(
784
+                $c->query(IValidator::class)
785
+            );
786
+        });
787
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
788
+
789
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
790
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
791
+            $manager->registerCapability(function () use ($c) {
792
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
793
+            });
794
+            return $manager;
795
+        });
796
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
797
+
798
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
799
+            $config = $c->getConfig();
800
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
801
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
802
+            $factory = new $factoryClass($this);
803
+            return $factory->getManager();
804
+        });
805
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
806
+
807
+        $this->registerService('ThemingDefaults', function(Server $c) {
808
+            /*
809 809
 			 * Dark magic for autoloader.
810 810
 			 * If we do a class_exists it will try to load the class which will
811 811
 			 * make composer cache the result. Resulting in errors when enabling
812 812
 			 * the theming app.
813 813
 			 */
814
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
815
-			if (isset($prefixes['OCA\\Theming\\'])) {
816
-				$classExists = true;
817
-			} else {
818
-				$classExists = false;
819
-			}
820
-
821
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
822
-				return new ThemingDefaults(
823
-					$c->getConfig(),
824
-					$c->getL10N('theming'),
825
-					$c->getURLGenerator(),
826
-					new \OC_Defaults(),
827
-					$c->getLazyRootFolder(),
828
-					$c->getMemCacheFactory()
829
-				);
830
-			}
831
-			return new \OC_Defaults();
832
-		});
833
-		$this->registerService(EventDispatcher::class, function () {
834
-			return new EventDispatcher();
835
-		});
836
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
837
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
838
-
839
-		$this->registerService('CryptoWrapper', function (Server $c) {
840
-			// FIXME: Instantiiated here due to cyclic dependency
841
-			$request = new Request(
842
-				[
843
-					'get' => $_GET,
844
-					'post' => $_POST,
845
-					'files' => $_FILES,
846
-					'server' => $_SERVER,
847
-					'env' => $_ENV,
848
-					'cookies' => $_COOKIE,
849
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
850
-						? $_SERVER['REQUEST_METHOD']
851
-						: null,
852
-				],
853
-				$c->getSecureRandom(),
854
-				$c->getConfig()
855
-			);
856
-
857
-			return new CryptoWrapper(
858
-				$c->getConfig(),
859
-				$c->getCrypto(),
860
-				$c->getSecureRandom(),
861
-				$request
862
-			);
863
-		});
864
-		$this->registerService('CsrfTokenManager', function (Server $c) {
865
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
866
-
867
-			return new CsrfTokenManager(
868
-				$tokenGenerator,
869
-				$c->query(SessionStorage::class)
870
-			);
871
-		});
872
-		$this->registerService(SessionStorage::class, function (Server $c) {
873
-			return new SessionStorage($c->getSession());
874
-		});
875
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
876
-			return new ContentSecurityPolicyManager();
877
-		});
878
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
879
-
880
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
881
-			return new ContentSecurityPolicyNonceManager(
882
-				$c->getCsrfTokenManager(),
883
-				$c->getRequest()
884
-			);
885
-		});
886
-
887
-		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
888
-			$config = $c->getConfig();
889
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
890
-			/** @var \OCP\Share\IProviderFactory $factory */
891
-			$factory = new $factoryClass($this);
892
-
893
-			$manager = new \OC\Share20\Manager(
894
-				$c->getLogger(),
895
-				$c->getConfig(),
896
-				$c->getSecureRandom(),
897
-				$c->getHasher(),
898
-				$c->getMountManager(),
899
-				$c->getGroupManager(),
900
-				$c->getL10N('core'),
901
-				$factory,
902
-				$c->getUserManager(),
903
-				$c->getLazyRootFolder(),
904
-				$c->getEventDispatcher()
905
-			);
906
-
907
-			return $manager;
908
-		});
909
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
910
-
911
-		$this->registerService('SettingsManager', function(Server $c) {
912
-			$manager = new \OC\Settings\Manager(
913
-				$c->getLogger(),
914
-				$c->getDatabaseConnection(),
915
-				$c->getL10N('lib'),
916
-				$c->getConfig(),
917
-				$c->getEncryptionManager(),
918
-				$c->getUserManager(),
919
-				$c->getLockingProvider(),
920
-				$c->getRequest(),
921
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
922
-				$c->getURLGenerator()
923
-			);
924
-			return $manager;
925
-		});
926
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
927
-			return new \OC\Files\AppData\Factory(
928
-				$c->getRootFolder(),
929
-				$c->getSystemConfig()
930
-			);
931
-		});
932
-
933
-		$this->registerService('LockdownManager', function (Server $c) {
934
-			return new LockdownManager();
935
-		});
936
-
937
-		$this->registerService('OCSDiscoveryService', function (Server $c) {
938
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
939
-		});
940
-
941
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
942
-			return new CloudIdManager();
943
-		});
944
-
945
-		/* To trick DI since we don't extend the DIContainer here */
946
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
947
-			return new CleanPreviewsBackgroundJob(
948
-				$c->getRootFolder(),
949
-				$c->getLogger(),
950
-				$c->getJobList(),
951
-				new TimeFactory()
952
-			);
953
-		});
954
-
955
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
956
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
957
-
958
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
959
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
960
-
961
-		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
962
-			return $c->query(\OCP\IUserSession::class)->getSession();
963
-		});
964
-	}
965
-
966
-	/**
967
-	 * @return \OCP\Contacts\IManager
968
-	 */
969
-	public function getContactsManager() {
970
-		return $this->query('ContactsManager');
971
-	}
972
-
973
-	/**
974
-	 * @return \OC\Encryption\Manager
975
-	 */
976
-	public function getEncryptionManager() {
977
-		return $this->query('EncryptionManager');
978
-	}
979
-
980
-	/**
981
-	 * @return \OC\Encryption\File
982
-	 */
983
-	public function getEncryptionFilesHelper() {
984
-		return $this->query('EncryptionFileHelper');
985
-	}
986
-
987
-	/**
988
-	 * @return \OCP\Encryption\Keys\IStorage
989
-	 */
990
-	public function getEncryptionKeyStorage() {
991
-		return $this->query('EncryptionKeyStorage');
992
-	}
993
-
994
-	/**
995
-	 * @return \OC\OCS\DiscoveryService
996
-	 */
997
-	public function getOCSDiscoveryService() {
998
-		return $this->query('OCSDiscoveryService');
999
-	}
1000
-
1001
-
1002
-	/**
1003
-	 * The current request object holding all information about the request
1004
-	 * currently being processed is returned from this method.
1005
-	 * In case the current execution was not initiated by a web request null is returned
1006
-	 *
1007
-	 * @return \OCP\IRequest
1008
-	 */
1009
-	public function getRequest() {
1010
-		return $this->query('Request');
1011
-	}
1012
-
1013
-	/**
1014
-	 * Returns the preview manager which can create preview images for a given file
1015
-	 *
1016
-	 * @return \OCP\IPreview
1017
-	 */
1018
-	public function getPreviewManager() {
1019
-		return $this->query('PreviewManager');
1020
-	}
1021
-
1022
-	/**
1023
-	 * Returns the tag manager which can get and set tags for different object types
1024
-	 *
1025
-	 * @see \OCP\ITagManager::load()
1026
-	 * @return \OCP\ITagManager
1027
-	 */
1028
-	public function getTagManager() {
1029
-		return $this->query('TagManager');
1030
-	}
1031
-
1032
-	/**
1033
-	 * Returns the system-tag manager
1034
-	 *
1035
-	 * @return \OCP\SystemTag\ISystemTagManager
1036
-	 *
1037
-	 * @since 9.0.0
1038
-	 */
1039
-	public function getSystemTagManager() {
1040
-		return $this->query('SystemTagManager');
1041
-	}
1042
-
1043
-	/**
1044
-	 * Returns the system-tag object mapper
1045
-	 *
1046
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1047
-	 *
1048
-	 * @since 9.0.0
1049
-	 */
1050
-	public function getSystemTagObjectMapper() {
1051
-		return $this->query('SystemTagObjectMapper');
1052
-	}
1053
-
1054
-	/**
1055
-	 * Returns the avatar manager, used for avatar functionality
1056
-	 *
1057
-	 * @return \OCP\IAvatarManager
1058
-	 */
1059
-	public function getAvatarManager() {
1060
-		return $this->query('AvatarManager');
1061
-	}
1062
-
1063
-	/**
1064
-	 * Returns the root folder of ownCloud's data directory
1065
-	 *
1066
-	 * @return \OCP\Files\IRootFolder
1067
-	 */
1068
-	public function getRootFolder() {
1069
-		return $this->query('LazyRootFolder');
1070
-	}
1071
-
1072
-	/**
1073
-	 * Returns the root folder of ownCloud's data directory
1074
-	 * This is the lazy variant so this gets only initialized once it
1075
-	 * is actually used.
1076
-	 *
1077
-	 * @return \OCP\Files\IRootFolder
1078
-	 */
1079
-	public function getLazyRootFolder() {
1080
-		return $this->query('LazyRootFolder');
1081
-	}
1082
-
1083
-	/**
1084
-	 * Returns a view to ownCloud's files folder
1085
-	 *
1086
-	 * @param string $userId user ID
1087
-	 * @return \OCP\Files\Folder|null
1088
-	 */
1089
-	public function getUserFolder($userId = null) {
1090
-		if ($userId === null) {
1091
-			$user = $this->getUserSession()->getUser();
1092
-			if (!$user) {
1093
-				return null;
1094
-			}
1095
-			$userId = $user->getUID();
1096
-		}
1097
-		$root = $this->getRootFolder();
1098
-		return $root->getUserFolder($userId);
1099
-	}
1100
-
1101
-	/**
1102
-	 * Returns an app-specific view in ownClouds data directory
1103
-	 *
1104
-	 * @return \OCP\Files\Folder
1105
-	 * @deprecated since 9.2.0 use IAppData
1106
-	 */
1107
-	public function getAppFolder() {
1108
-		$dir = '/' . \OC_App::getCurrentApp();
1109
-		$root = $this->getRootFolder();
1110
-		if (!$root->nodeExists($dir)) {
1111
-			$folder = $root->newFolder($dir);
1112
-		} else {
1113
-			$folder = $root->get($dir);
1114
-		}
1115
-		return $folder;
1116
-	}
1117
-
1118
-	/**
1119
-	 * @return \OC\User\Manager
1120
-	 */
1121
-	public function getUserManager() {
1122
-		return $this->query('UserManager');
1123
-	}
1124
-
1125
-	/**
1126
-	 * @return \OC\Group\Manager
1127
-	 */
1128
-	public function getGroupManager() {
1129
-		return $this->query('GroupManager');
1130
-	}
1131
-
1132
-	/**
1133
-	 * @return \OC\User\Session
1134
-	 */
1135
-	public function getUserSession() {
1136
-		return $this->query('UserSession');
1137
-	}
1138
-
1139
-	/**
1140
-	 * @return \OCP\ISession
1141
-	 */
1142
-	public function getSession() {
1143
-		return $this->query('UserSession')->getSession();
1144
-	}
1145
-
1146
-	/**
1147
-	 * @param \OCP\ISession $session
1148
-	 */
1149
-	public function setSession(\OCP\ISession $session) {
1150
-		$this->query(SessionStorage::class)->setSession($session);
1151
-		$this->query('UserSession')->setSession($session);
1152
-		$this->query(Store::class)->setSession($session);
1153
-	}
1154
-
1155
-	/**
1156
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1157
-	 */
1158
-	public function getTwoFactorAuthManager() {
1159
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1160
-	}
1161
-
1162
-	/**
1163
-	 * @return \OC\NavigationManager
1164
-	 */
1165
-	public function getNavigationManager() {
1166
-		return $this->query('NavigationManager');
1167
-	}
1168
-
1169
-	/**
1170
-	 * @return \OCP\IConfig
1171
-	 */
1172
-	public function getConfig() {
1173
-		return $this->query('AllConfig');
1174
-	}
1175
-
1176
-	/**
1177
-	 * @internal For internal use only
1178
-	 * @return \OC\SystemConfig
1179
-	 */
1180
-	public function getSystemConfig() {
1181
-		return $this->query('SystemConfig');
1182
-	}
1183
-
1184
-	/**
1185
-	 * Returns the app config manager
1186
-	 *
1187
-	 * @return \OCP\IAppConfig
1188
-	 */
1189
-	public function getAppConfig() {
1190
-		return $this->query('AppConfig');
1191
-	}
1192
-
1193
-	/**
1194
-	 * @return \OCP\L10N\IFactory
1195
-	 */
1196
-	public function getL10NFactory() {
1197
-		return $this->query('L10NFactory');
1198
-	}
1199
-
1200
-	/**
1201
-	 * get an L10N instance
1202
-	 *
1203
-	 * @param string $app appid
1204
-	 * @param string $lang
1205
-	 * @return IL10N
1206
-	 */
1207
-	public function getL10N($app, $lang = null) {
1208
-		return $this->getL10NFactory()->get($app, $lang);
1209
-	}
1210
-
1211
-	/**
1212
-	 * @return \OCP\IURLGenerator
1213
-	 */
1214
-	public function getURLGenerator() {
1215
-		return $this->query('URLGenerator');
1216
-	}
1217
-
1218
-	/**
1219
-	 * @return \OCP\IHelper
1220
-	 */
1221
-	public function getHelper() {
1222
-		return $this->query('AppHelper');
1223
-	}
1224
-
1225
-	/**
1226
-	 * @return AppFetcher
1227
-	 */
1228
-	public function getAppFetcher() {
1229
-		return $this->query('AppFetcher');
1230
-	}
1231
-
1232
-	/**
1233
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1234
-	 * getMemCacheFactory() instead.
1235
-	 *
1236
-	 * @return \OCP\ICache
1237
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1238
-	 */
1239
-	public function getCache() {
1240
-		return $this->query('UserCache');
1241
-	}
1242
-
1243
-	/**
1244
-	 * Returns an \OCP\CacheFactory instance
1245
-	 *
1246
-	 * @return \OCP\ICacheFactory
1247
-	 */
1248
-	public function getMemCacheFactory() {
1249
-		return $this->query('MemCacheFactory');
1250
-	}
1251
-
1252
-	/**
1253
-	 * Returns an \OC\RedisFactory instance
1254
-	 *
1255
-	 * @return \OC\RedisFactory
1256
-	 */
1257
-	public function getGetRedisFactory() {
1258
-		return $this->query('RedisFactory');
1259
-	}
1260
-
1261
-
1262
-	/**
1263
-	 * Returns the current session
1264
-	 *
1265
-	 * @return \OCP\IDBConnection
1266
-	 */
1267
-	public function getDatabaseConnection() {
1268
-		return $this->query('DatabaseConnection');
1269
-	}
1270
-
1271
-	/**
1272
-	 * Returns the activity manager
1273
-	 *
1274
-	 * @return \OCP\Activity\IManager
1275
-	 */
1276
-	public function getActivityManager() {
1277
-		return $this->query('ActivityManager');
1278
-	}
1279
-
1280
-	/**
1281
-	 * Returns an job list for controlling background jobs
1282
-	 *
1283
-	 * @return \OCP\BackgroundJob\IJobList
1284
-	 */
1285
-	public function getJobList() {
1286
-		return $this->query('JobList');
1287
-	}
1288
-
1289
-	/**
1290
-	 * Returns a logger instance
1291
-	 *
1292
-	 * @return \OCP\ILogger
1293
-	 */
1294
-	public function getLogger() {
1295
-		return $this->query('Logger');
1296
-	}
1297
-
1298
-	/**
1299
-	 * Returns a router for generating and matching urls
1300
-	 *
1301
-	 * @return \OCP\Route\IRouter
1302
-	 */
1303
-	public function getRouter() {
1304
-		return $this->query('Router');
1305
-	}
1306
-
1307
-	/**
1308
-	 * Returns a search instance
1309
-	 *
1310
-	 * @return \OCP\ISearch
1311
-	 */
1312
-	public function getSearch() {
1313
-		return $this->query('Search');
1314
-	}
1315
-
1316
-	/**
1317
-	 * Returns a SecureRandom instance
1318
-	 *
1319
-	 * @return \OCP\Security\ISecureRandom
1320
-	 */
1321
-	public function getSecureRandom() {
1322
-		return $this->query('SecureRandom');
1323
-	}
1324
-
1325
-	/**
1326
-	 * Returns a Crypto instance
1327
-	 *
1328
-	 * @return \OCP\Security\ICrypto
1329
-	 */
1330
-	public function getCrypto() {
1331
-		return $this->query('Crypto');
1332
-	}
1333
-
1334
-	/**
1335
-	 * Returns a Hasher instance
1336
-	 *
1337
-	 * @return \OCP\Security\IHasher
1338
-	 */
1339
-	public function getHasher() {
1340
-		return $this->query('Hasher');
1341
-	}
1342
-
1343
-	/**
1344
-	 * Returns a CredentialsManager instance
1345
-	 *
1346
-	 * @return \OCP\Security\ICredentialsManager
1347
-	 */
1348
-	public function getCredentialsManager() {
1349
-		return $this->query('CredentialsManager');
1350
-	}
1351
-
1352
-	/**
1353
-	 * Returns an instance of the HTTP helper class
1354
-	 *
1355
-	 * @deprecated Use getHTTPClientService()
1356
-	 * @return \OC\HTTPHelper
1357
-	 */
1358
-	public function getHTTPHelper() {
1359
-		return $this->query('HTTPHelper');
1360
-	}
1361
-
1362
-	/**
1363
-	 * Get the certificate manager for the user
1364
-	 *
1365
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1366
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1367
-	 */
1368
-	public function getCertificateManager($userId = '') {
1369
-		if ($userId === '') {
1370
-			$userSession = $this->getUserSession();
1371
-			$user = $userSession->getUser();
1372
-			if (is_null($user)) {
1373
-				return null;
1374
-			}
1375
-			$userId = $user->getUID();
1376
-		}
1377
-		return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1378
-	}
1379
-
1380
-	/**
1381
-	 * Returns an instance of the HTTP client service
1382
-	 *
1383
-	 * @return \OCP\Http\Client\IClientService
1384
-	 */
1385
-	public function getHTTPClientService() {
1386
-		return $this->query('HttpClientService');
1387
-	}
1388
-
1389
-	/**
1390
-	 * Create a new event source
1391
-	 *
1392
-	 * @return \OCP\IEventSource
1393
-	 */
1394
-	public function createEventSource() {
1395
-		return new \OC_EventSource();
1396
-	}
1397
-
1398
-	/**
1399
-	 * Get the active event logger
1400
-	 *
1401
-	 * The returned logger only logs data when debug mode is enabled
1402
-	 *
1403
-	 * @return \OCP\Diagnostics\IEventLogger
1404
-	 */
1405
-	public function getEventLogger() {
1406
-		return $this->query('EventLogger');
1407
-	}
1408
-
1409
-	/**
1410
-	 * Get the active query logger
1411
-	 *
1412
-	 * The returned logger only logs data when debug mode is enabled
1413
-	 *
1414
-	 * @return \OCP\Diagnostics\IQueryLogger
1415
-	 */
1416
-	public function getQueryLogger() {
1417
-		return $this->query('QueryLogger');
1418
-	}
1419
-
1420
-	/**
1421
-	 * Get the manager for temporary files and folders
1422
-	 *
1423
-	 * @return \OCP\ITempManager
1424
-	 */
1425
-	public function getTempManager() {
1426
-		return $this->query('TempManager');
1427
-	}
1428
-
1429
-	/**
1430
-	 * Get the app manager
1431
-	 *
1432
-	 * @return \OCP\App\IAppManager
1433
-	 */
1434
-	public function getAppManager() {
1435
-		return $this->query('AppManager');
1436
-	}
1437
-
1438
-	/**
1439
-	 * Creates a new mailer
1440
-	 *
1441
-	 * @return \OCP\Mail\IMailer
1442
-	 */
1443
-	public function getMailer() {
1444
-		return $this->query('Mailer');
1445
-	}
1446
-
1447
-	/**
1448
-	 * Get the webroot
1449
-	 *
1450
-	 * @return string
1451
-	 */
1452
-	public function getWebRoot() {
1453
-		return $this->webRoot;
1454
-	}
1455
-
1456
-	/**
1457
-	 * @return \OC\OCSClient
1458
-	 */
1459
-	public function getOcsClient() {
1460
-		return $this->query('OcsClient');
1461
-	}
1462
-
1463
-	/**
1464
-	 * @return \OCP\IDateTimeZone
1465
-	 */
1466
-	public function getDateTimeZone() {
1467
-		return $this->query('DateTimeZone');
1468
-	}
1469
-
1470
-	/**
1471
-	 * @return \OCP\IDateTimeFormatter
1472
-	 */
1473
-	public function getDateTimeFormatter() {
1474
-		return $this->query('DateTimeFormatter');
1475
-	}
1476
-
1477
-	/**
1478
-	 * @return \OCP\Files\Config\IMountProviderCollection
1479
-	 */
1480
-	public function getMountProviderCollection() {
1481
-		return $this->query('MountConfigManager');
1482
-	}
1483
-
1484
-	/**
1485
-	 * Get the IniWrapper
1486
-	 *
1487
-	 * @return IniGetWrapper
1488
-	 */
1489
-	public function getIniWrapper() {
1490
-		return $this->query('IniWrapper');
1491
-	}
1492
-
1493
-	/**
1494
-	 * @return \OCP\Command\IBus
1495
-	 */
1496
-	public function getCommandBus() {
1497
-		return $this->query('AsyncCommandBus');
1498
-	}
1499
-
1500
-	/**
1501
-	 * Get the trusted domain helper
1502
-	 *
1503
-	 * @return TrustedDomainHelper
1504
-	 */
1505
-	public function getTrustedDomainHelper() {
1506
-		return $this->query('TrustedDomainHelper');
1507
-	}
1508
-
1509
-	/**
1510
-	 * Get the locking provider
1511
-	 *
1512
-	 * @return \OCP\Lock\ILockingProvider
1513
-	 * @since 8.1.0
1514
-	 */
1515
-	public function getLockingProvider() {
1516
-		return $this->query('LockingProvider');
1517
-	}
1518
-
1519
-	/**
1520
-	 * @return \OCP\Files\Mount\IMountManager
1521
-	 **/
1522
-	function getMountManager() {
1523
-		return $this->query('MountManager');
1524
-	}
1525
-
1526
-	/** @return \OCP\Files\Config\IUserMountCache */
1527
-	function getUserMountCache() {
1528
-		return $this->query('UserMountCache');
1529
-	}
1530
-
1531
-	/**
1532
-	 * Get the MimeTypeDetector
1533
-	 *
1534
-	 * @return \OCP\Files\IMimeTypeDetector
1535
-	 */
1536
-	public function getMimeTypeDetector() {
1537
-		return $this->query('MimeTypeDetector');
1538
-	}
1539
-
1540
-	/**
1541
-	 * Get the MimeTypeLoader
1542
-	 *
1543
-	 * @return \OCP\Files\IMimeTypeLoader
1544
-	 */
1545
-	public function getMimeTypeLoader() {
1546
-		return $this->query('MimeTypeLoader');
1547
-	}
1548
-
1549
-	/**
1550
-	 * Get the manager of all the capabilities
1551
-	 *
1552
-	 * @return \OC\CapabilitiesManager
1553
-	 */
1554
-	public function getCapabilitiesManager() {
1555
-		return $this->query('CapabilitiesManager');
1556
-	}
1557
-
1558
-	/**
1559
-	 * Get the EventDispatcher
1560
-	 *
1561
-	 * @return EventDispatcherInterface
1562
-	 * @since 8.2.0
1563
-	 */
1564
-	public function getEventDispatcher() {
1565
-		return $this->query('EventDispatcher');
1566
-	}
1567
-
1568
-	/**
1569
-	 * Get the Notification Manager
1570
-	 *
1571
-	 * @return \OCP\Notification\IManager
1572
-	 * @since 8.2.0
1573
-	 */
1574
-	public function getNotificationManager() {
1575
-		return $this->query('NotificationManager');
1576
-	}
1577
-
1578
-	/**
1579
-	 * @return \OCP\Comments\ICommentsManager
1580
-	 */
1581
-	public function getCommentsManager() {
1582
-		return $this->query('CommentsManager');
1583
-	}
1584
-
1585
-	/**
1586
-	 * @return \OC_Defaults
1587
-	 */
1588
-	public function getThemingDefaults() {
1589
-		return $this->query('ThemingDefaults');
1590
-	}
1591
-
1592
-	/**
1593
-	 * @return \OC\IntegrityCheck\Checker
1594
-	 */
1595
-	public function getIntegrityCodeChecker() {
1596
-		return $this->query('IntegrityCodeChecker');
1597
-	}
1598
-
1599
-	/**
1600
-	 * @return \OC\Session\CryptoWrapper
1601
-	 */
1602
-	public function getSessionCryptoWrapper() {
1603
-		return $this->query('CryptoWrapper');
1604
-	}
1605
-
1606
-	/**
1607
-	 * @return CsrfTokenManager
1608
-	 */
1609
-	public function getCsrfTokenManager() {
1610
-		return $this->query('CsrfTokenManager');
1611
-	}
1612
-
1613
-	/**
1614
-	 * @return Throttler
1615
-	 */
1616
-	public function getBruteForceThrottler() {
1617
-		return $this->query('Throttler');
1618
-	}
1619
-
1620
-	/**
1621
-	 * @return IContentSecurityPolicyManager
1622
-	 */
1623
-	public function getContentSecurityPolicyManager() {
1624
-		return $this->query('ContentSecurityPolicyManager');
1625
-	}
1626
-
1627
-	/**
1628
-	 * @return ContentSecurityPolicyNonceManager
1629
-	 */
1630
-	public function getContentSecurityPolicyNonceManager() {
1631
-		return $this->query('ContentSecurityPolicyNonceManager');
1632
-	}
1633
-
1634
-	/**
1635
-	 * Not a public API as of 8.2, wait for 9.0
1636
-	 *
1637
-	 * @return \OCA\Files_External\Service\BackendService
1638
-	 */
1639
-	public function getStoragesBackendService() {
1640
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1641
-	}
1642
-
1643
-	/**
1644
-	 * Not a public API as of 8.2, wait for 9.0
1645
-	 *
1646
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1647
-	 */
1648
-	public function getGlobalStoragesService() {
1649
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1650
-	}
1651
-
1652
-	/**
1653
-	 * Not a public API as of 8.2, wait for 9.0
1654
-	 *
1655
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1656
-	 */
1657
-	public function getUserGlobalStoragesService() {
1658
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1659
-	}
1660
-
1661
-	/**
1662
-	 * Not a public API as of 8.2, wait for 9.0
1663
-	 *
1664
-	 * @return \OCA\Files_External\Service\UserStoragesService
1665
-	 */
1666
-	public function getUserStoragesService() {
1667
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1668
-	}
1669
-
1670
-	/**
1671
-	 * @return \OCP\Share\IManager
1672
-	 */
1673
-	public function getShareManager() {
1674
-		return $this->query('ShareManager');
1675
-	}
1676
-
1677
-	/**
1678
-	 * Returns the LDAP Provider
1679
-	 *
1680
-	 * @return \OCP\LDAP\ILDAPProvider
1681
-	 */
1682
-	public function getLDAPProvider() {
1683
-		return $this->query('LDAPProvider');
1684
-	}
1685
-
1686
-	/**
1687
-	 * @return \OCP\Settings\IManager
1688
-	 */
1689
-	public function getSettingsManager() {
1690
-		return $this->query('SettingsManager');
1691
-	}
1692
-
1693
-	/**
1694
-	 * @return \OCP\Files\IAppData
1695
-	 */
1696
-	public function getAppDataDir($app) {
1697
-		/** @var \OC\Files\AppData\Factory $factory */
1698
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1699
-		return $factory->get($app);
1700
-	}
1701
-
1702
-	/**
1703
-	 * @return \OCP\Lockdown\ILockdownManager
1704
-	 */
1705
-	public function getLockdownManager() {
1706
-		return $this->query('LockdownManager');
1707
-	}
1708
-
1709
-	/**
1710
-	 * @return \OCP\Federation\ICloudIdManager
1711
-	 */
1712
-	public function getCloudIdManager() {
1713
-		return $this->query(ICloudIdManager::class);
1714
-	}
814
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
815
+            if (isset($prefixes['OCA\\Theming\\'])) {
816
+                $classExists = true;
817
+            } else {
818
+                $classExists = false;
819
+            }
820
+
821
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
822
+                return new ThemingDefaults(
823
+                    $c->getConfig(),
824
+                    $c->getL10N('theming'),
825
+                    $c->getURLGenerator(),
826
+                    new \OC_Defaults(),
827
+                    $c->getLazyRootFolder(),
828
+                    $c->getMemCacheFactory()
829
+                );
830
+            }
831
+            return new \OC_Defaults();
832
+        });
833
+        $this->registerService(EventDispatcher::class, function () {
834
+            return new EventDispatcher();
835
+        });
836
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
837
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
838
+
839
+        $this->registerService('CryptoWrapper', function (Server $c) {
840
+            // FIXME: Instantiiated here due to cyclic dependency
841
+            $request = new Request(
842
+                [
843
+                    'get' => $_GET,
844
+                    'post' => $_POST,
845
+                    'files' => $_FILES,
846
+                    'server' => $_SERVER,
847
+                    'env' => $_ENV,
848
+                    'cookies' => $_COOKIE,
849
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
850
+                        ? $_SERVER['REQUEST_METHOD']
851
+                        : null,
852
+                ],
853
+                $c->getSecureRandom(),
854
+                $c->getConfig()
855
+            );
856
+
857
+            return new CryptoWrapper(
858
+                $c->getConfig(),
859
+                $c->getCrypto(),
860
+                $c->getSecureRandom(),
861
+                $request
862
+            );
863
+        });
864
+        $this->registerService('CsrfTokenManager', function (Server $c) {
865
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
866
+
867
+            return new CsrfTokenManager(
868
+                $tokenGenerator,
869
+                $c->query(SessionStorage::class)
870
+            );
871
+        });
872
+        $this->registerService(SessionStorage::class, function (Server $c) {
873
+            return new SessionStorage($c->getSession());
874
+        });
875
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
876
+            return new ContentSecurityPolicyManager();
877
+        });
878
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
879
+
880
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
881
+            return new ContentSecurityPolicyNonceManager(
882
+                $c->getCsrfTokenManager(),
883
+                $c->getRequest()
884
+            );
885
+        });
886
+
887
+        $this->registerService(\OCP\Share\IManager::class, function(Server $c) {
888
+            $config = $c->getConfig();
889
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
890
+            /** @var \OCP\Share\IProviderFactory $factory */
891
+            $factory = new $factoryClass($this);
892
+
893
+            $manager = new \OC\Share20\Manager(
894
+                $c->getLogger(),
895
+                $c->getConfig(),
896
+                $c->getSecureRandom(),
897
+                $c->getHasher(),
898
+                $c->getMountManager(),
899
+                $c->getGroupManager(),
900
+                $c->getL10N('core'),
901
+                $factory,
902
+                $c->getUserManager(),
903
+                $c->getLazyRootFolder(),
904
+                $c->getEventDispatcher()
905
+            );
906
+
907
+            return $manager;
908
+        });
909
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
910
+
911
+        $this->registerService('SettingsManager', function(Server $c) {
912
+            $manager = new \OC\Settings\Manager(
913
+                $c->getLogger(),
914
+                $c->getDatabaseConnection(),
915
+                $c->getL10N('lib'),
916
+                $c->getConfig(),
917
+                $c->getEncryptionManager(),
918
+                $c->getUserManager(),
919
+                $c->getLockingProvider(),
920
+                $c->getRequest(),
921
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
922
+                $c->getURLGenerator()
923
+            );
924
+            return $manager;
925
+        });
926
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
927
+            return new \OC\Files\AppData\Factory(
928
+                $c->getRootFolder(),
929
+                $c->getSystemConfig()
930
+            );
931
+        });
932
+
933
+        $this->registerService('LockdownManager', function (Server $c) {
934
+            return new LockdownManager();
935
+        });
936
+
937
+        $this->registerService('OCSDiscoveryService', function (Server $c) {
938
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
939
+        });
940
+
941
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
942
+            return new CloudIdManager();
943
+        });
944
+
945
+        /* To trick DI since we don't extend the DIContainer here */
946
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
947
+            return new CleanPreviewsBackgroundJob(
948
+                $c->getRootFolder(),
949
+                $c->getLogger(),
950
+                $c->getJobList(),
951
+                new TimeFactory()
952
+            );
953
+        });
954
+
955
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
956
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
957
+
958
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
959
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
960
+
961
+        $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
962
+            return $c->query(\OCP\IUserSession::class)->getSession();
963
+        });
964
+    }
965
+
966
+    /**
967
+     * @return \OCP\Contacts\IManager
968
+     */
969
+    public function getContactsManager() {
970
+        return $this->query('ContactsManager');
971
+    }
972
+
973
+    /**
974
+     * @return \OC\Encryption\Manager
975
+     */
976
+    public function getEncryptionManager() {
977
+        return $this->query('EncryptionManager');
978
+    }
979
+
980
+    /**
981
+     * @return \OC\Encryption\File
982
+     */
983
+    public function getEncryptionFilesHelper() {
984
+        return $this->query('EncryptionFileHelper');
985
+    }
986
+
987
+    /**
988
+     * @return \OCP\Encryption\Keys\IStorage
989
+     */
990
+    public function getEncryptionKeyStorage() {
991
+        return $this->query('EncryptionKeyStorage');
992
+    }
993
+
994
+    /**
995
+     * @return \OC\OCS\DiscoveryService
996
+     */
997
+    public function getOCSDiscoveryService() {
998
+        return $this->query('OCSDiscoveryService');
999
+    }
1000
+
1001
+
1002
+    /**
1003
+     * The current request object holding all information about the request
1004
+     * currently being processed is returned from this method.
1005
+     * In case the current execution was not initiated by a web request null is returned
1006
+     *
1007
+     * @return \OCP\IRequest
1008
+     */
1009
+    public function getRequest() {
1010
+        return $this->query('Request');
1011
+    }
1012
+
1013
+    /**
1014
+     * Returns the preview manager which can create preview images for a given file
1015
+     *
1016
+     * @return \OCP\IPreview
1017
+     */
1018
+    public function getPreviewManager() {
1019
+        return $this->query('PreviewManager');
1020
+    }
1021
+
1022
+    /**
1023
+     * Returns the tag manager which can get and set tags for different object types
1024
+     *
1025
+     * @see \OCP\ITagManager::load()
1026
+     * @return \OCP\ITagManager
1027
+     */
1028
+    public function getTagManager() {
1029
+        return $this->query('TagManager');
1030
+    }
1031
+
1032
+    /**
1033
+     * Returns the system-tag manager
1034
+     *
1035
+     * @return \OCP\SystemTag\ISystemTagManager
1036
+     *
1037
+     * @since 9.0.0
1038
+     */
1039
+    public function getSystemTagManager() {
1040
+        return $this->query('SystemTagManager');
1041
+    }
1042
+
1043
+    /**
1044
+     * Returns the system-tag object mapper
1045
+     *
1046
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1047
+     *
1048
+     * @since 9.0.0
1049
+     */
1050
+    public function getSystemTagObjectMapper() {
1051
+        return $this->query('SystemTagObjectMapper');
1052
+    }
1053
+
1054
+    /**
1055
+     * Returns the avatar manager, used for avatar functionality
1056
+     *
1057
+     * @return \OCP\IAvatarManager
1058
+     */
1059
+    public function getAvatarManager() {
1060
+        return $this->query('AvatarManager');
1061
+    }
1062
+
1063
+    /**
1064
+     * Returns the root folder of ownCloud's data directory
1065
+     *
1066
+     * @return \OCP\Files\IRootFolder
1067
+     */
1068
+    public function getRootFolder() {
1069
+        return $this->query('LazyRootFolder');
1070
+    }
1071
+
1072
+    /**
1073
+     * Returns the root folder of ownCloud's data directory
1074
+     * This is the lazy variant so this gets only initialized once it
1075
+     * is actually used.
1076
+     *
1077
+     * @return \OCP\Files\IRootFolder
1078
+     */
1079
+    public function getLazyRootFolder() {
1080
+        return $this->query('LazyRootFolder');
1081
+    }
1082
+
1083
+    /**
1084
+     * Returns a view to ownCloud's files folder
1085
+     *
1086
+     * @param string $userId user ID
1087
+     * @return \OCP\Files\Folder|null
1088
+     */
1089
+    public function getUserFolder($userId = null) {
1090
+        if ($userId === null) {
1091
+            $user = $this->getUserSession()->getUser();
1092
+            if (!$user) {
1093
+                return null;
1094
+            }
1095
+            $userId = $user->getUID();
1096
+        }
1097
+        $root = $this->getRootFolder();
1098
+        return $root->getUserFolder($userId);
1099
+    }
1100
+
1101
+    /**
1102
+     * Returns an app-specific view in ownClouds data directory
1103
+     *
1104
+     * @return \OCP\Files\Folder
1105
+     * @deprecated since 9.2.0 use IAppData
1106
+     */
1107
+    public function getAppFolder() {
1108
+        $dir = '/' . \OC_App::getCurrentApp();
1109
+        $root = $this->getRootFolder();
1110
+        if (!$root->nodeExists($dir)) {
1111
+            $folder = $root->newFolder($dir);
1112
+        } else {
1113
+            $folder = $root->get($dir);
1114
+        }
1115
+        return $folder;
1116
+    }
1117
+
1118
+    /**
1119
+     * @return \OC\User\Manager
1120
+     */
1121
+    public function getUserManager() {
1122
+        return $this->query('UserManager');
1123
+    }
1124
+
1125
+    /**
1126
+     * @return \OC\Group\Manager
1127
+     */
1128
+    public function getGroupManager() {
1129
+        return $this->query('GroupManager');
1130
+    }
1131
+
1132
+    /**
1133
+     * @return \OC\User\Session
1134
+     */
1135
+    public function getUserSession() {
1136
+        return $this->query('UserSession');
1137
+    }
1138
+
1139
+    /**
1140
+     * @return \OCP\ISession
1141
+     */
1142
+    public function getSession() {
1143
+        return $this->query('UserSession')->getSession();
1144
+    }
1145
+
1146
+    /**
1147
+     * @param \OCP\ISession $session
1148
+     */
1149
+    public function setSession(\OCP\ISession $session) {
1150
+        $this->query(SessionStorage::class)->setSession($session);
1151
+        $this->query('UserSession')->setSession($session);
1152
+        $this->query(Store::class)->setSession($session);
1153
+    }
1154
+
1155
+    /**
1156
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1157
+     */
1158
+    public function getTwoFactorAuthManager() {
1159
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1160
+    }
1161
+
1162
+    /**
1163
+     * @return \OC\NavigationManager
1164
+     */
1165
+    public function getNavigationManager() {
1166
+        return $this->query('NavigationManager');
1167
+    }
1168
+
1169
+    /**
1170
+     * @return \OCP\IConfig
1171
+     */
1172
+    public function getConfig() {
1173
+        return $this->query('AllConfig');
1174
+    }
1175
+
1176
+    /**
1177
+     * @internal For internal use only
1178
+     * @return \OC\SystemConfig
1179
+     */
1180
+    public function getSystemConfig() {
1181
+        return $this->query('SystemConfig');
1182
+    }
1183
+
1184
+    /**
1185
+     * Returns the app config manager
1186
+     *
1187
+     * @return \OCP\IAppConfig
1188
+     */
1189
+    public function getAppConfig() {
1190
+        return $this->query('AppConfig');
1191
+    }
1192
+
1193
+    /**
1194
+     * @return \OCP\L10N\IFactory
1195
+     */
1196
+    public function getL10NFactory() {
1197
+        return $this->query('L10NFactory');
1198
+    }
1199
+
1200
+    /**
1201
+     * get an L10N instance
1202
+     *
1203
+     * @param string $app appid
1204
+     * @param string $lang
1205
+     * @return IL10N
1206
+     */
1207
+    public function getL10N($app, $lang = null) {
1208
+        return $this->getL10NFactory()->get($app, $lang);
1209
+    }
1210
+
1211
+    /**
1212
+     * @return \OCP\IURLGenerator
1213
+     */
1214
+    public function getURLGenerator() {
1215
+        return $this->query('URLGenerator');
1216
+    }
1217
+
1218
+    /**
1219
+     * @return \OCP\IHelper
1220
+     */
1221
+    public function getHelper() {
1222
+        return $this->query('AppHelper');
1223
+    }
1224
+
1225
+    /**
1226
+     * @return AppFetcher
1227
+     */
1228
+    public function getAppFetcher() {
1229
+        return $this->query('AppFetcher');
1230
+    }
1231
+
1232
+    /**
1233
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1234
+     * getMemCacheFactory() instead.
1235
+     *
1236
+     * @return \OCP\ICache
1237
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1238
+     */
1239
+    public function getCache() {
1240
+        return $this->query('UserCache');
1241
+    }
1242
+
1243
+    /**
1244
+     * Returns an \OCP\CacheFactory instance
1245
+     *
1246
+     * @return \OCP\ICacheFactory
1247
+     */
1248
+    public function getMemCacheFactory() {
1249
+        return $this->query('MemCacheFactory');
1250
+    }
1251
+
1252
+    /**
1253
+     * Returns an \OC\RedisFactory instance
1254
+     *
1255
+     * @return \OC\RedisFactory
1256
+     */
1257
+    public function getGetRedisFactory() {
1258
+        return $this->query('RedisFactory');
1259
+    }
1260
+
1261
+
1262
+    /**
1263
+     * Returns the current session
1264
+     *
1265
+     * @return \OCP\IDBConnection
1266
+     */
1267
+    public function getDatabaseConnection() {
1268
+        return $this->query('DatabaseConnection');
1269
+    }
1270
+
1271
+    /**
1272
+     * Returns the activity manager
1273
+     *
1274
+     * @return \OCP\Activity\IManager
1275
+     */
1276
+    public function getActivityManager() {
1277
+        return $this->query('ActivityManager');
1278
+    }
1279
+
1280
+    /**
1281
+     * Returns an job list for controlling background jobs
1282
+     *
1283
+     * @return \OCP\BackgroundJob\IJobList
1284
+     */
1285
+    public function getJobList() {
1286
+        return $this->query('JobList');
1287
+    }
1288
+
1289
+    /**
1290
+     * Returns a logger instance
1291
+     *
1292
+     * @return \OCP\ILogger
1293
+     */
1294
+    public function getLogger() {
1295
+        return $this->query('Logger');
1296
+    }
1297
+
1298
+    /**
1299
+     * Returns a router for generating and matching urls
1300
+     *
1301
+     * @return \OCP\Route\IRouter
1302
+     */
1303
+    public function getRouter() {
1304
+        return $this->query('Router');
1305
+    }
1306
+
1307
+    /**
1308
+     * Returns a search instance
1309
+     *
1310
+     * @return \OCP\ISearch
1311
+     */
1312
+    public function getSearch() {
1313
+        return $this->query('Search');
1314
+    }
1315
+
1316
+    /**
1317
+     * Returns a SecureRandom instance
1318
+     *
1319
+     * @return \OCP\Security\ISecureRandom
1320
+     */
1321
+    public function getSecureRandom() {
1322
+        return $this->query('SecureRandom');
1323
+    }
1324
+
1325
+    /**
1326
+     * Returns a Crypto instance
1327
+     *
1328
+     * @return \OCP\Security\ICrypto
1329
+     */
1330
+    public function getCrypto() {
1331
+        return $this->query('Crypto');
1332
+    }
1333
+
1334
+    /**
1335
+     * Returns a Hasher instance
1336
+     *
1337
+     * @return \OCP\Security\IHasher
1338
+     */
1339
+    public function getHasher() {
1340
+        return $this->query('Hasher');
1341
+    }
1342
+
1343
+    /**
1344
+     * Returns a CredentialsManager instance
1345
+     *
1346
+     * @return \OCP\Security\ICredentialsManager
1347
+     */
1348
+    public function getCredentialsManager() {
1349
+        return $this->query('CredentialsManager');
1350
+    }
1351
+
1352
+    /**
1353
+     * Returns an instance of the HTTP helper class
1354
+     *
1355
+     * @deprecated Use getHTTPClientService()
1356
+     * @return \OC\HTTPHelper
1357
+     */
1358
+    public function getHTTPHelper() {
1359
+        return $this->query('HTTPHelper');
1360
+    }
1361
+
1362
+    /**
1363
+     * Get the certificate manager for the user
1364
+     *
1365
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1366
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1367
+     */
1368
+    public function getCertificateManager($userId = '') {
1369
+        if ($userId === '') {
1370
+            $userSession = $this->getUserSession();
1371
+            $user = $userSession->getUser();
1372
+            if (is_null($user)) {
1373
+                return null;
1374
+            }
1375
+            $userId = $user->getUID();
1376
+        }
1377
+        return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1378
+    }
1379
+
1380
+    /**
1381
+     * Returns an instance of the HTTP client service
1382
+     *
1383
+     * @return \OCP\Http\Client\IClientService
1384
+     */
1385
+    public function getHTTPClientService() {
1386
+        return $this->query('HttpClientService');
1387
+    }
1388
+
1389
+    /**
1390
+     * Create a new event source
1391
+     *
1392
+     * @return \OCP\IEventSource
1393
+     */
1394
+    public function createEventSource() {
1395
+        return new \OC_EventSource();
1396
+    }
1397
+
1398
+    /**
1399
+     * Get the active event logger
1400
+     *
1401
+     * The returned logger only logs data when debug mode is enabled
1402
+     *
1403
+     * @return \OCP\Diagnostics\IEventLogger
1404
+     */
1405
+    public function getEventLogger() {
1406
+        return $this->query('EventLogger');
1407
+    }
1408
+
1409
+    /**
1410
+     * Get the active query logger
1411
+     *
1412
+     * The returned logger only logs data when debug mode is enabled
1413
+     *
1414
+     * @return \OCP\Diagnostics\IQueryLogger
1415
+     */
1416
+    public function getQueryLogger() {
1417
+        return $this->query('QueryLogger');
1418
+    }
1419
+
1420
+    /**
1421
+     * Get the manager for temporary files and folders
1422
+     *
1423
+     * @return \OCP\ITempManager
1424
+     */
1425
+    public function getTempManager() {
1426
+        return $this->query('TempManager');
1427
+    }
1428
+
1429
+    /**
1430
+     * Get the app manager
1431
+     *
1432
+     * @return \OCP\App\IAppManager
1433
+     */
1434
+    public function getAppManager() {
1435
+        return $this->query('AppManager');
1436
+    }
1437
+
1438
+    /**
1439
+     * Creates a new mailer
1440
+     *
1441
+     * @return \OCP\Mail\IMailer
1442
+     */
1443
+    public function getMailer() {
1444
+        return $this->query('Mailer');
1445
+    }
1446
+
1447
+    /**
1448
+     * Get the webroot
1449
+     *
1450
+     * @return string
1451
+     */
1452
+    public function getWebRoot() {
1453
+        return $this->webRoot;
1454
+    }
1455
+
1456
+    /**
1457
+     * @return \OC\OCSClient
1458
+     */
1459
+    public function getOcsClient() {
1460
+        return $this->query('OcsClient');
1461
+    }
1462
+
1463
+    /**
1464
+     * @return \OCP\IDateTimeZone
1465
+     */
1466
+    public function getDateTimeZone() {
1467
+        return $this->query('DateTimeZone');
1468
+    }
1469
+
1470
+    /**
1471
+     * @return \OCP\IDateTimeFormatter
1472
+     */
1473
+    public function getDateTimeFormatter() {
1474
+        return $this->query('DateTimeFormatter');
1475
+    }
1476
+
1477
+    /**
1478
+     * @return \OCP\Files\Config\IMountProviderCollection
1479
+     */
1480
+    public function getMountProviderCollection() {
1481
+        return $this->query('MountConfigManager');
1482
+    }
1483
+
1484
+    /**
1485
+     * Get the IniWrapper
1486
+     *
1487
+     * @return IniGetWrapper
1488
+     */
1489
+    public function getIniWrapper() {
1490
+        return $this->query('IniWrapper');
1491
+    }
1492
+
1493
+    /**
1494
+     * @return \OCP\Command\IBus
1495
+     */
1496
+    public function getCommandBus() {
1497
+        return $this->query('AsyncCommandBus');
1498
+    }
1499
+
1500
+    /**
1501
+     * Get the trusted domain helper
1502
+     *
1503
+     * @return TrustedDomainHelper
1504
+     */
1505
+    public function getTrustedDomainHelper() {
1506
+        return $this->query('TrustedDomainHelper');
1507
+    }
1508
+
1509
+    /**
1510
+     * Get the locking provider
1511
+     *
1512
+     * @return \OCP\Lock\ILockingProvider
1513
+     * @since 8.1.0
1514
+     */
1515
+    public function getLockingProvider() {
1516
+        return $this->query('LockingProvider');
1517
+    }
1518
+
1519
+    /**
1520
+     * @return \OCP\Files\Mount\IMountManager
1521
+     **/
1522
+    function getMountManager() {
1523
+        return $this->query('MountManager');
1524
+    }
1525
+
1526
+    /** @return \OCP\Files\Config\IUserMountCache */
1527
+    function getUserMountCache() {
1528
+        return $this->query('UserMountCache');
1529
+    }
1530
+
1531
+    /**
1532
+     * Get the MimeTypeDetector
1533
+     *
1534
+     * @return \OCP\Files\IMimeTypeDetector
1535
+     */
1536
+    public function getMimeTypeDetector() {
1537
+        return $this->query('MimeTypeDetector');
1538
+    }
1539
+
1540
+    /**
1541
+     * Get the MimeTypeLoader
1542
+     *
1543
+     * @return \OCP\Files\IMimeTypeLoader
1544
+     */
1545
+    public function getMimeTypeLoader() {
1546
+        return $this->query('MimeTypeLoader');
1547
+    }
1548
+
1549
+    /**
1550
+     * Get the manager of all the capabilities
1551
+     *
1552
+     * @return \OC\CapabilitiesManager
1553
+     */
1554
+    public function getCapabilitiesManager() {
1555
+        return $this->query('CapabilitiesManager');
1556
+    }
1557
+
1558
+    /**
1559
+     * Get the EventDispatcher
1560
+     *
1561
+     * @return EventDispatcherInterface
1562
+     * @since 8.2.0
1563
+     */
1564
+    public function getEventDispatcher() {
1565
+        return $this->query('EventDispatcher');
1566
+    }
1567
+
1568
+    /**
1569
+     * Get the Notification Manager
1570
+     *
1571
+     * @return \OCP\Notification\IManager
1572
+     * @since 8.2.0
1573
+     */
1574
+    public function getNotificationManager() {
1575
+        return $this->query('NotificationManager');
1576
+    }
1577
+
1578
+    /**
1579
+     * @return \OCP\Comments\ICommentsManager
1580
+     */
1581
+    public function getCommentsManager() {
1582
+        return $this->query('CommentsManager');
1583
+    }
1584
+
1585
+    /**
1586
+     * @return \OC_Defaults
1587
+     */
1588
+    public function getThemingDefaults() {
1589
+        return $this->query('ThemingDefaults');
1590
+    }
1591
+
1592
+    /**
1593
+     * @return \OC\IntegrityCheck\Checker
1594
+     */
1595
+    public function getIntegrityCodeChecker() {
1596
+        return $this->query('IntegrityCodeChecker');
1597
+    }
1598
+
1599
+    /**
1600
+     * @return \OC\Session\CryptoWrapper
1601
+     */
1602
+    public function getSessionCryptoWrapper() {
1603
+        return $this->query('CryptoWrapper');
1604
+    }
1605
+
1606
+    /**
1607
+     * @return CsrfTokenManager
1608
+     */
1609
+    public function getCsrfTokenManager() {
1610
+        return $this->query('CsrfTokenManager');
1611
+    }
1612
+
1613
+    /**
1614
+     * @return Throttler
1615
+     */
1616
+    public function getBruteForceThrottler() {
1617
+        return $this->query('Throttler');
1618
+    }
1619
+
1620
+    /**
1621
+     * @return IContentSecurityPolicyManager
1622
+     */
1623
+    public function getContentSecurityPolicyManager() {
1624
+        return $this->query('ContentSecurityPolicyManager');
1625
+    }
1626
+
1627
+    /**
1628
+     * @return ContentSecurityPolicyNonceManager
1629
+     */
1630
+    public function getContentSecurityPolicyNonceManager() {
1631
+        return $this->query('ContentSecurityPolicyNonceManager');
1632
+    }
1633
+
1634
+    /**
1635
+     * Not a public API as of 8.2, wait for 9.0
1636
+     *
1637
+     * @return \OCA\Files_External\Service\BackendService
1638
+     */
1639
+    public function getStoragesBackendService() {
1640
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1641
+    }
1642
+
1643
+    /**
1644
+     * Not a public API as of 8.2, wait for 9.0
1645
+     *
1646
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1647
+     */
1648
+    public function getGlobalStoragesService() {
1649
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1650
+    }
1651
+
1652
+    /**
1653
+     * Not a public API as of 8.2, wait for 9.0
1654
+     *
1655
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1656
+     */
1657
+    public function getUserGlobalStoragesService() {
1658
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1659
+    }
1660
+
1661
+    /**
1662
+     * Not a public API as of 8.2, wait for 9.0
1663
+     *
1664
+     * @return \OCA\Files_External\Service\UserStoragesService
1665
+     */
1666
+    public function getUserStoragesService() {
1667
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1668
+    }
1669
+
1670
+    /**
1671
+     * @return \OCP\Share\IManager
1672
+     */
1673
+    public function getShareManager() {
1674
+        return $this->query('ShareManager');
1675
+    }
1676
+
1677
+    /**
1678
+     * Returns the LDAP Provider
1679
+     *
1680
+     * @return \OCP\LDAP\ILDAPProvider
1681
+     */
1682
+    public function getLDAPProvider() {
1683
+        return $this->query('LDAPProvider');
1684
+    }
1685
+
1686
+    /**
1687
+     * @return \OCP\Settings\IManager
1688
+     */
1689
+    public function getSettingsManager() {
1690
+        return $this->query('SettingsManager');
1691
+    }
1692
+
1693
+    /**
1694
+     * @return \OCP\Files\IAppData
1695
+     */
1696
+    public function getAppDataDir($app) {
1697
+        /** @var \OC\Files\AppData\Factory $factory */
1698
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1699
+        return $factory->get($app);
1700
+    }
1701
+
1702
+    /**
1703
+     * @return \OCP\Lockdown\ILockdownManager
1704
+     */
1705
+    public function getLockdownManager() {
1706
+        return $this->query('LockdownManager');
1707
+    }
1708
+
1709
+    /**
1710
+     * @return \OCP\Federation\ICloudIdManager
1711
+     */
1712
+    public function getCloudIdManager() {
1713
+        return $this->query(ICloudIdManager::class);
1714
+    }
1715 1715
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
131 131
 		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
132 132
 
133
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
133
+		$this->registerService(\OCP\IPreview::class, function(Server $c) {
134 134
 			return new PreviewManager(
135 135
 				$c->getConfig(),
136 136
 				$c->getRootFolder(),
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 		});
142 142
 		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
143 143
 
144
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
144
+		$this->registerService(\OC\Preview\Watcher::class, function(Server $c) {
145 145
 			return new \OC\Preview\Watcher(
146 146
 				$c->getAppDataDir('preview')
147 147
 			);
148 148
 		});
149 149
 
150
-		$this->registerService('EncryptionManager', function (Server $c) {
150
+		$this->registerService('EncryptionManager', function(Server $c) {
151 151
 			$view = new View();
152 152
 			$util = new Encryption\Util(
153 153
 				$view,
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			);
166 166
 		});
167 167
 
168
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
168
+		$this->registerService('EncryptionFileHelper', function(Server $c) {
169 169
 			$util = new Encryption\Util(
170 170
 				new View(),
171 171
 				$c->getUserManager(),
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			return new Encryption\File($util);
176 176
 		});
177 177
 
178
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
178
+		$this->registerService('EncryptionKeyStorage', function(Server $c) {
179 179
 			$view = new View();
180 180
 			$util = new Encryption\Util(
181 181
 				$view,
@@ -186,32 +186,32 @@  discard block
 block discarded – undo
186 186
 
187 187
 			return new Encryption\Keys\Storage($view, $util);
188 188
 		});
189
-		$this->registerService('TagMapper', function (Server $c) {
189
+		$this->registerService('TagMapper', function(Server $c) {
190 190
 			return new TagMapper($c->getDatabaseConnection());
191 191
 		});
192 192
 
193
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
193
+		$this->registerService(\OCP\ITagManager::class, function(Server $c) {
194 194
 			$tagMapper = $c->query('TagMapper');
195 195
 			return new TagManager($tagMapper, $c->getUserSession());
196 196
 		});
197 197
 		$this->registerAlias('TagManager', \OCP\ITagManager::class);
198 198
 
199
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
199
+		$this->registerService('SystemTagManagerFactory', function(Server $c) {
200 200
 			$config = $c->getConfig();
201 201
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
202 202
 			/** @var \OC\SystemTag\ManagerFactory $factory */
203 203
 			$factory = new $factoryClass($this);
204 204
 			return $factory;
205 205
 		});
206
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
206
+		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) {
207 207
 			return $c->query('SystemTagManagerFactory')->getManager();
208 208
 		});
209 209
 		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
210 210
 
211
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
211
+		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) {
212 212
 			return $c->query('SystemTagManagerFactory')->getObjectMapper();
213 213
 		});
214
-		$this->registerService('RootFolder', function (Server $c) {
214
+		$this->registerService('RootFolder', function(Server $c) {
215 215
 			$manager = \OC\Files\Filesystem::getMountManager(null);
216 216
 			$view = new View();
217 217
 			$root = new Root(
@@ -239,30 +239,30 @@  discard block
 block discarded – undo
239 239
 		});
240 240
 		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
241 241
 
242
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
242
+		$this->registerService(\OCP\IUserManager::class, function(Server $c) {
243 243
 			$config = $c->getConfig();
244 244
 			return new \OC\User\Manager($config);
245 245
 		});
246 246
 		$this->registerAlias('UserManager', \OCP\IUserManager::class);
247 247
 
248
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
248
+		$this->registerService(\OCP\IGroupManager::class, function(Server $c) {
249 249
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
250
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
250
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
251 251
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
252 252
 			});
253
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
253
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) {
254 254
 				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
255 255
 			});
256
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
256
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
257 257
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
258 258
 			});
259
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
259
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
260 260
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
261 261
 			});
262
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
262
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
263 263
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
264 264
 			});
265
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
265
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
266 266
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
267 267
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
268 268
 				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 			return new Store($session, $logger, $tokenProvider);
283 283
 		});
284 284
 		$this->registerAlias(IStore::class, Store::class);
285
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
285
+		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) {
286 286
 			$dbConnection = $c->getDatabaseConnection();
287 287
 			return new Authentication\Token\DefaultTokenMapper($dbConnection);
288 288
 		});
289
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
289
+		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) {
290 290
 			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
291 291
 			$crypto = $c->getCrypto();
292 292
 			$config = $c->getConfig();
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		});
297 297
 		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
298 298
 
299
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
299
+		$this->registerService(\OCP\IUserSession::class, function(Server $c) {
300 300
 			$manager = $c->getUserManager();
301 301
 			$session = new \OC\Session\Memory('');
302 302
 			$timeFactory = new TimeFactory();
@@ -309,40 +309,40 @@  discard block
 block discarded – undo
309 309
 			}
310 310
 
311 311
 			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
312
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
312
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
313 313
 				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
314 314
 			});
315
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
315
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
316 316
 				/** @var $user \OC\User\User */
317 317
 				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
318 318
 			});
319
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
319
+			$userSession->listen('\OC\User', 'preDelete', function($user) {
320 320
 				/** @var $user \OC\User\User */
321 321
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
322 322
 			});
323
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
323
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
324 324
 				/** @var $user \OC\User\User */
325 325
 				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
326 326
 			});
327
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
327
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
328 328
 				/** @var $user \OC\User\User */
329 329
 				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
330 330
 			});
331
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
331
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
332 332
 				/** @var $user \OC\User\User */
333 333
 				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
334 334
 			});
335
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
335
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
336 336
 				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
337 337
 			});
338
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
338
+			$userSession->listen('\OC\User', 'postLogin', function($user, $password) {
339 339
 				/** @var $user \OC\User\User */
340 340
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
341 341
 			});
342
-			$userSession->listen('\OC\User', 'logout', function () {
342
+			$userSession->listen('\OC\User', 'logout', function() {
343 343
 				\OC_Hook::emit('OC_User', 'logout', array());
344 344
 			});
345
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
345
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) {
346 346
 				/** @var $user \OC\User\User */
347 347
 				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
348 348
 			});
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 		});
351 351
 		$this->registerAlias('UserSession', \OCP\IUserSession::class);
352 352
 
353
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
353
+		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) {
354 354
 			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
355 355
 		});
356 356
 
357 357
 		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
358 358
 		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
359 359
 
360
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
360
+		$this->registerService(\OC\AllConfig::class, function(Server $c) {
361 361
 			return new \OC\AllConfig(
362 362
 				$c->getSystemConfig()
363 363
 			);
@@ -365,17 +365,17 @@  discard block
 block discarded – undo
365 365
 		$this->registerAlias('AllConfig', \OC\AllConfig::class);
366 366
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
367 367
 
368
-		$this->registerService('SystemConfig', function ($c) use ($config) {
368
+		$this->registerService('SystemConfig', function($c) use ($config) {
369 369
 			return new \OC\SystemConfig($config);
370 370
 		});
371 371
 
372
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
372
+		$this->registerService(\OC\AppConfig::class, function(Server $c) {
373 373
 			return new \OC\AppConfig($c->getDatabaseConnection());
374 374
 		});
375 375
 		$this->registerAlias('AppConfig', \OC\AppConfig::class);
376 376
 		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
377 377
 
378
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
378
+		$this->registerService(\OCP\L10N\IFactory::class, function(Server $c) {
379 379
 			return new \OC\L10N\Factory(
380 380
 				$c->getConfig(),
381 381
 				$c->getRequest(),
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		});
386 386
 		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
387 387
 
388
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
388
+		$this->registerService(\OCP\IURLGenerator::class, function(Server $c) {
389 389
 			$config = $c->getConfig();
390 390
 			$cacheFactory = $c->getMemCacheFactory();
391 391
 			return new \OC\URLGenerator(
@@ -395,10 +395,10 @@  discard block
 block discarded – undo
395 395
 		});
396 396
 		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
397 397
 
398
-		$this->registerService('AppHelper', function ($c) {
398
+		$this->registerService('AppHelper', function($c) {
399 399
 			return new \OC\AppHelper();
400 400
 		});
401
-		$this->registerService('AppFetcher', function ($c) {
401
+		$this->registerService('AppFetcher', function($c) {
402 402
 			return new AppFetcher(
403 403
 				$this->getAppDataDir('appstore'),
404 404
 				$this->getHTTPClientService(),
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 				$this->getConfig()
407 407
 			);
408 408
 		});
409
-		$this->registerService('CategoryFetcher', function ($c) {
409
+		$this->registerService('CategoryFetcher', function($c) {
410 410
 			return new CategoryFetcher(
411 411
 				$this->getAppDataDir('appstore'),
412 412
 				$this->getHTTPClientService(),
@@ -415,21 +415,21 @@  discard block
 block discarded – undo
415 415
 			);
416 416
 		});
417 417
 
418
-		$this->registerService(\OCP\ICache::class, function ($c) {
418
+		$this->registerService(\OCP\ICache::class, function($c) {
419 419
 			return new Cache\File();
420 420
 		});
421 421
 		$this->registerAlias('UserCache', \OCP\ICache::class);
422 422
 
423
-		$this->registerService(Factory::class, function (Server $c) {
423
+		$this->registerService(Factory::class, function(Server $c) {
424 424
 			$config = $c->getConfig();
425 425
 
426 426
 			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
427 427
 				$v = \OC_App::getAppVersions();
428
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
428
+				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php'));
429 429
 				$version = implode(',', $v);
430 430
 				$instanceId = \OC_Util::getInstanceId();
431 431
 				$path = \OC::$SERVERROOT;
432
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
432
+				$prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT);
433 433
 				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
434 434
 					$config->getSystemValue('memcache.local', null),
435 435
 					$config->getSystemValue('memcache.distributed', null),
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 		$this->registerAlias('MemCacheFactory', Factory::class);
447 447
 		$this->registerAlias(ICacheFactory::class, Factory::class);
448 448
 
449
-		$this->registerService('RedisFactory', function (Server $c) {
449
+		$this->registerService('RedisFactory', function(Server $c) {
450 450
 			$systemConfig = $c->getSystemConfig();
451 451
 			return new RedisFactory($systemConfig);
452 452
 		});
453 453
 
454
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
454
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
455 455
 			return new \OC\Activity\Manager(
456 456
 				$c->getRequest(),
457 457
 				$c->getUserSession(),
@@ -461,14 +461,14 @@  discard block
 block discarded – undo
461 461
 		});
462 462
 		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
463 463
 
464
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
464
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
465 465
 			return new \OC\Activity\EventMerger(
466 466
 				$c->getL10N('lib')
467 467
 			);
468 468
 		});
469 469
 		$this->registerAlias(IValidator::class, Validator::class);
470 470
 
471
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
471
+		$this->registerService(\OCP\IAvatarManager::class, function(Server $c) {
472 472
 			return new AvatarManager(
473 473
 				$c->getUserManager(),
474 474
 				$c->getAppDataDir('avatar'),
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 		});
480 480
 		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
481 481
 
482
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
482
+		$this->registerService(\OCP\ILogger::class, function(Server $c) {
483 483
 			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
484 484
 			$logger = Log::getLogClass($logType);
485 485
 			call_user_func(array($logger, 'init'));
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		});
489 489
 		$this->registerAlias('Logger', \OCP\ILogger::class);
490 490
 
491
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
491
+		$this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) {
492 492
 			$config = $c->getConfig();
493 493
 			return new \OC\BackgroundJob\JobList(
494 494
 				$c->getDatabaseConnection(),
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 		});
499 499
 		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
500 500
 
501
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
501
+		$this->registerService(\OCP\Route\IRouter::class, function(Server $c) {
502 502
 			$cacheFactory = $c->getMemCacheFactory();
503 503
 			$logger = $c->getLogger();
504 504
 			if ($cacheFactory->isAvailable()) {
@@ -510,32 +510,32 @@  discard block
 block discarded – undo
510 510
 		});
511 511
 		$this->registerAlias('Router', \OCP\Route\IRouter::class);
512 512
 
513
-		$this->registerService(\OCP\ISearch::class, function ($c) {
513
+		$this->registerService(\OCP\ISearch::class, function($c) {
514 514
 			return new Search();
515 515
 		});
516 516
 		$this->registerAlias('Search', \OCP\ISearch::class);
517 517
 
518
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
518
+		$this->registerService(\OCP\Security\ISecureRandom::class, function($c) {
519 519
 			return new SecureRandom();
520 520
 		});
521 521
 		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
522 522
 
523
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
523
+		$this->registerService(\OCP\Security\ICrypto::class, function(Server $c) {
524 524
 			return new Crypto($c->getConfig(), $c->getSecureRandom());
525 525
 		});
526 526
 		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
527 527
 
528
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
528
+		$this->registerService(\OCP\Security\IHasher::class, function(Server $c) {
529 529
 			return new Hasher($c->getConfig());
530 530
 		});
531 531
 		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
532 532
 
533
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
533
+		$this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) {
534 534
 			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
535 535
 		});
536 536
 		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
537 537
 
538
-		$this->registerService(IDBConnection::class, function (Server $c) {
538
+		$this->registerService(IDBConnection::class, function(Server $c) {
539 539
 			$systemConfig = $c->getSystemConfig();
540 540
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
541 541
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		});
550 550
 		$this->registerAlias('DatabaseConnection', IDBConnection::class);
551 551
 
552
-		$this->registerService('HTTPHelper', function (Server $c) {
552
+		$this->registerService('HTTPHelper', function(Server $c) {
553 553
 			$config = $c->getConfig();
554 554
 			return new HTTPHelper(
555 555
 				$config,
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 			);
558 558
 		});
559 559
 
560
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
560
+		$this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) {
561 561
 			$user = \OC_User::getUser();
562 562
 			$uid = $user ? $user : null;
563 563
 			return new ClientService(
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		});
568 568
 		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
569 569
 
570
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
570
+		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) {
571 571
 			if ($c->getSystemConfig()->getValue('debug', false)) {
572 572
 				return new EventLogger();
573 573
 			} else {
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 		});
577 577
 		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
578 578
 
579
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
579
+		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) {
580 580
 			if ($c->getSystemConfig()->getValue('debug', false)) {
581 581
 				return new QueryLogger();
582 582
 			} else {
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		});
586 586
 		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
587 587
 
588
-		$this->registerService(TempManager::class, function (Server $c) {
588
+		$this->registerService(TempManager::class, function(Server $c) {
589 589
 			return new TempManager(
590 590
 				$c->getLogger(),
591 591
 				$c->getConfig()
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 		$this->registerAlias('TempManager', TempManager::class);
595 595
 		$this->registerAlias(ITempManager::class, TempManager::class);
596 596
 
597
-		$this->registerService(AppManager::class, function (Server $c) {
597
+		$this->registerService(AppManager::class, function(Server $c) {
598 598
 			return new \OC\App\AppManager(
599 599
 				$c->getUserSession(),
600 600
 				$c->getAppConfig(),
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 		$this->registerAlias('AppManager', AppManager::class);
607 607
 		$this->registerAlias(IAppManager::class, AppManager::class);
608 608
 
609
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
609
+		$this->registerService(\OCP\IDateTimeZone::class, function(Server $c) {
610 610
 			return new DateTimeZone(
611 611
 				$c->getConfig(),
612 612
 				$c->getSession()
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		});
615 615
 		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
616 616
 
617
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
617
+		$this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) {
618 618
 			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
619 619
 
620 620
 			return new DateTimeFormatter(
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 		});
625 625
 		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
626 626
 
627
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
627
+		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) {
628 628
 			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
629 629
 			$listener = new UserMountCacheListener($mountCache);
630 630
 			$listener->listen($c->getUserManager());
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 		});
633 633
 		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
634 634
 
635
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
635
+		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) {
636 636
 			$loader = \OC\Files\Filesystem::getLoader();
637 637
 			$mountCache = $c->query('UserMountCache');
638
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
638
+			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
639 639
 
640 640
 			// builtin providers
641 641
 
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 		});
649 649
 		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
650 650
 
651
-		$this->registerService('IniWrapper', function ($c) {
651
+		$this->registerService('IniWrapper', function($c) {
652 652
 			return new IniGetWrapper();
653 653
 		});
654
-		$this->registerService('AsyncCommandBus', function (Server $c) {
654
+		$this->registerService('AsyncCommandBus', function(Server $c) {
655 655
 			$jobList = $c->getJobList();
656 656
 			return new AsyncBus($jobList);
657 657
 		});
658
-		$this->registerService('TrustedDomainHelper', function ($c) {
658
+		$this->registerService('TrustedDomainHelper', function($c) {
659 659
 			return new TrustedDomainHelper($this->getConfig());
660 660
 		});
661 661
 		$this->registerService('Throttler', function(Server $c) {
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
 				$c->getConfig()
667 667
 			);
668 668
 		});
669
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
669
+		$this->registerService('IntegrityCodeChecker', function(Server $c) {
670 670
 			// IConfig and IAppManager requires a working database. This code
671 671
 			// might however be called when ownCloud is not yet setup.
672
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
672
+			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
673 673
 				$config = $c->getConfig();
674 674
 				$appManager = $c->getAppManager();
675 675
 			} else {
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 					$c->getTempManager()
688 688
 			);
689 689
 		});
690
-		$this->registerService(\OCP\IRequest::class, function ($c) {
690
+		$this->registerService(\OCP\IRequest::class, function($c) {
691 691
 			if (isset($this['urlParams'])) {
692 692
 				$urlParams = $this['urlParams'];
693 693
 			} else {
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		});
724 724
 		$this->registerAlias('Request', \OCP\IRequest::class);
725 725
 
726
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
726
+		$this->registerService(\OCP\Mail\IMailer::class, function(Server $c) {
727 727
 			return new Mailer(
728 728
 				$c->getConfig(),
729 729
 				$c->getLogger(),
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 		$this->registerService('LDAPProvider', function(Server $c) {
736 736
 			$config = $c->getConfig();
737 737
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
738
-			if(is_null($factoryClass)) {
738
+			if (is_null($factoryClass)) {
739 739
 				throw new \Exception('ldapProviderFactory not set');
740 740
 			}
741 741
 			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
742 742
 			$factory = new $factoryClass($this);
743 743
 			return $factory->getLDAPProvider();
744 744
 		});
745
-		$this->registerService('LockingProvider', function (Server $c) {
745
+		$this->registerService('LockingProvider', function(Server $c) {
746 746
 			$ini = $c->getIniWrapper();
747 747
 			$config = $c->getConfig();
748 748
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -758,37 +758,37 @@  discard block
 block discarded – undo
758 758
 			return new NoopLockingProvider();
759 759
 		});
760 760
 
761
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
761
+		$this->registerService(\OCP\Files\Mount\IMountManager::class, function() {
762 762
 			return new \OC\Files\Mount\Manager();
763 763
 		});
764 764
 		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
765 765
 
766
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
766
+		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) {
767 767
 			return new \OC\Files\Type\Detection(
768 768
 				$c->getURLGenerator(),
769 769
 				\OC::$configDir,
770
-				\OC::$SERVERROOT . '/resources/config/'
770
+				\OC::$SERVERROOT.'/resources/config/'
771 771
 			);
772 772
 		});
773 773
 		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
774 774
 
775
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
775
+		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) {
776 776
 			return new \OC\Files\Type\Loader(
777 777
 				$c->getDatabaseConnection()
778 778
 			);
779 779
 		});
780 780
 		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
781 781
 
782
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
782
+		$this->registerService(\OCP\Notification\IManager::class, function(Server $c) {
783 783
 			return new Manager(
784 784
 				$c->query(IValidator::class)
785 785
 			);
786 786
 		});
787 787
 		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
788 788
 
789
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
789
+		$this->registerService(\OC\CapabilitiesManager::class, function(Server $c) {
790 790
 			$manager = new \OC\CapabilitiesManager($c->getLogger());
791
-			$manager->registerCapability(function () use ($c) {
791
+			$manager->registerCapability(function() use ($c) {
792 792
 				return new \OC\OCS\CoreCapabilities($c->getConfig());
793 793
 			});
794 794
 			return $manager;
@@ -830,13 +830,13 @@  discard block
 block discarded – undo
830 830
 			}
831 831
 			return new \OC_Defaults();
832 832
 		});
833
-		$this->registerService(EventDispatcher::class, function () {
833
+		$this->registerService(EventDispatcher::class, function() {
834 834
 			return new EventDispatcher();
835 835
 		});
836 836
 		$this->registerAlias('EventDispatcher', EventDispatcher::class);
837 837
 		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
838 838
 
839
-		$this->registerService('CryptoWrapper', function (Server $c) {
839
+		$this->registerService('CryptoWrapper', function(Server $c) {
840 840
 			// FIXME: Instantiiated here due to cyclic dependency
841 841
 			$request = new Request(
842 842
 				[
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 				$request
862 862
 			);
863 863
 		});
864
-		$this->registerService('CsrfTokenManager', function (Server $c) {
864
+		$this->registerService('CsrfTokenManager', function(Server $c) {
865 865
 			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
866 866
 
867 867
 			return new CsrfTokenManager(
@@ -869,10 +869,10 @@  discard block
 block discarded – undo
869 869
 				$c->query(SessionStorage::class)
870 870
 			);
871 871
 		});
872
-		$this->registerService(SessionStorage::class, function (Server $c) {
872
+		$this->registerService(SessionStorage::class, function(Server $c) {
873 873
 			return new SessionStorage($c->getSession());
874 874
 		});
875
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
875
+		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) {
876 876
 			return new ContentSecurityPolicyManager();
877 877
 		});
878 878
 		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
@@ -923,27 +923,27 @@  discard block
 block discarded – undo
923 923
 			);
924 924
 			return $manager;
925 925
 		});
926
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
926
+		$this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) {
927 927
 			return new \OC\Files\AppData\Factory(
928 928
 				$c->getRootFolder(),
929 929
 				$c->getSystemConfig()
930 930
 			);
931 931
 		});
932 932
 
933
-		$this->registerService('LockdownManager', function (Server $c) {
933
+		$this->registerService('LockdownManager', function(Server $c) {
934 934
 			return new LockdownManager();
935 935
 		});
936 936
 
937
-		$this->registerService('OCSDiscoveryService', function (Server $c) {
937
+		$this->registerService('OCSDiscoveryService', function(Server $c) {
938 938
 			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
939 939
 		});
940 940
 
941
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
941
+		$this->registerService(ICloudIdManager::class, function(Server $c) {
942 942
 			return new CloudIdManager();
943 943
 		});
944 944
 
945 945
 		/* To trick DI since we don't extend the DIContainer here */
946
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
946
+		$this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) {
947 947
 			return new CleanPreviewsBackgroundJob(
948 948
 				$c->getRootFolder(),
949 949
 				$c->getLogger(),
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 	 * @deprecated since 9.2.0 use IAppData
1106 1106
 	 */
1107 1107
 	public function getAppFolder() {
1108
-		$dir = '/' . \OC_App::getCurrentApp();
1108
+		$dir = '/'.\OC_App::getCurrentApp();
1109 1109
 		$root = $this->getRootFolder();
1110 1110
 		if (!$root->nodeExists($dir)) {
1111 1111
 			$folder = $root->newFolder($dir);
Please login to merge, or discard this patch.