Passed
Push — master ( af8aba...40edab )
by John
10:01 queued 16s
created
lib/private/Security/RateLimiting/Limiter.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -31,73 +31,73 @@
 block discarded – undo
31 31
 use OCP\IUser;
32 32
 
33 33
 class Limiter {
34
-	/** @var IBackend */
35
-	private $backend;
36
-	/** @var ITimeFactory */
37
-	private $timeFactory;
34
+    /** @var IBackend */
35
+    private $backend;
36
+    /** @var ITimeFactory */
37
+    private $timeFactory;
38 38
 
39
-	/**
40
-	 * @param ITimeFactory $timeFactory
41
-	 * @param IBackend $backend
42
-	 */
43
-	public function __construct(ITimeFactory $timeFactory,
44
-								IBackend $backend) {
45
-		$this->backend = $backend;
46
-		$this->timeFactory = $timeFactory;
47
-	}
39
+    /**
40
+     * @param ITimeFactory $timeFactory
41
+     * @param IBackend $backend
42
+     */
43
+    public function __construct(ITimeFactory $timeFactory,
44
+                                IBackend $backend) {
45
+        $this->backend = $backend;
46
+        $this->timeFactory = $timeFactory;
47
+    }
48 48
 
49
-	/**
50
-	 * @param string $methodIdentifier
51
-	 * @param string $userIdentifier
52
-	 * @param int $period
53
-	 * @param int $limit
54
-	 * @throws RateLimitExceededException
55
-	 */
56
-	private function register(string $methodIdentifier,
57
-							  string $userIdentifier,
58
-							  int $period,
59
-							  int $limit): void {
60
-		$existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, $period);
61
-		if ($existingAttempts >= $limit) {
62
-			throw new RateLimitExceededException();
63
-		}
49
+    /**
50
+     * @param string $methodIdentifier
51
+     * @param string $userIdentifier
52
+     * @param int $period
53
+     * @param int $limit
54
+     * @throws RateLimitExceededException
55
+     */
56
+    private function register(string $methodIdentifier,
57
+                                string $userIdentifier,
58
+                                int $period,
59
+                                int $limit): void {
60
+        $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, $period);
61
+        if ($existingAttempts >= $limit) {
62
+            throw new RateLimitExceededException();
63
+        }
64 64
 
65
-		$this->backend->registerAttempt($methodIdentifier, $userIdentifier, $this->timeFactory->getTime());
66
-	}
65
+        $this->backend->registerAttempt($methodIdentifier, $userIdentifier, $this->timeFactory->getTime());
66
+    }
67 67
 
68
-	/**
69
-	 * Registers attempt for an anonymous request
70
-	 *
71
-	 * @param string $identifier
72
-	 * @param int $anonLimit
73
-	 * @param int $anonPeriod
74
-	 * @param string $ip
75
-	 * @throws RateLimitExceededException
76
-	 */
77
-	public function registerAnonRequest(string $identifier,
78
-										int $anonLimit,
79
-										int $anonPeriod,
80
-										string $ip): void {
81
-		$ipSubnet = (new IpAddress($ip))->getSubnet();
68
+    /**
69
+     * Registers attempt for an anonymous request
70
+     *
71
+     * @param string $identifier
72
+     * @param int $anonLimit
73
+     * @param int $anonPeriod
74
+     * @param string $ip
75
+     * @throws RateLimitExceededException
76
+     */
77
+    public function registerAnonRequest(string $identifier,
78
+                                        int $anonLimit,
79
+                                        int $anonPeriod,
80
+                                        string $ip): void {
81
+        $ipSubnet = (new IpAddress($ip))->getSubnet();
82 82
 
83
-		$anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
84
-		$this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
85
-	}
83
+        $anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
84
+        $this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
85
+    }
86 86
 
87
-	/**
88
-	 * Registers attempt for an authenticated request
89
-	 *
90
-	 * @param string $identifier
91
-	 * @param int $userLimit
92
-	 * @param int $userPeriod
93
-	 * @param IUser $user
94
-	 * @throws RateLimitExceededException
95
-	 */
96
-	public function registerUserRequest(string $identifier,
97
-										int $userLimit,
98
-										int $userPeriod,
99
-										IUser $user): void {
100
-		$userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
101
-		$this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
102
-	}
87
+    /**
88
+     * Registers attempt for an authenticated request
89
+     *
90
+     * @param string $identifier
91
+     * @param int $userLimit
92
+     * @param int $userPeriod
93
+     * @param IUser $user
94
+     * @throws RateLimitExceededException
95
+     */
96
+    public function registerUserRequest(string $identifier,
97
+                                        int $userLimit,
98
+                                        int $userPeriod,
99
+                                        IUser $user): void {
100
+        $userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
101
+        $this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
102
+    }
103 103
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 										string $ip): void {
81 81
 		$ipSubnet = (new IpAddress($ip))->getSubnet();
82 82
 
83
-		$anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet);
83
+		$anonHashIdentifier = hash('sha512', 'anon::'.$identifier.$ipSubnet);
84 84
 		$this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit);
85 85
 	}
86 86
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 										int $userLimit,
98 98
 										int $userPeriod,
99 99
 										IUser $user): void {
100
-		$userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID());
100
+		$userHashIdentifier = hash('sha512', 'user::'.$identifier.$user->getUID());
101 101
 		$this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit);
102 102
 	}
103 103
 }
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Indentation   +1894 added lines, -1894 removed lines patch added patch discarded remove patch
@@ -169,1903 +169,1903 @@
 block discarded – undo
169 169
  * TODO: hookup all manager classes
170 170
  */
171 171
 class Server extends ServerContainer implements IServerContainer {
172
-	/** @var string */
173
-	private $webRoot;
174
-
175
-	/**
176
-	 * @param string $webRoot
177
-	 * @param \OC\Config $config
178
-	 */
179
-	public function __construct($webRoot, \OC\Config $config) {
180
-		parent::__construct();
181
-		$this->webRoot = $webRoot;
182
-
183
-		// To find out if we are running from CLI or not
184
-		$this->registerParameter('isCLI', \OC::$CLI);
185
-
186
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
187
-			return $c;
188
-		});
189
-
190
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
191
-		$this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
192
-
193
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
194
-		$this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
195
-
196
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
197
-		$this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
198
-
199
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
200
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
201
-
202
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
203
-
204
-
205
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
206
-			return new PreviewManager(
207
-				$c->getConfig(),
208
-				$c->getRootFolder(),
209
-				$c->getAppDataDir('preview'),
210
-				$c->getEventDispatcher(),
211
-				$c->getGeneratorHelper(),
212
-				$c->getSession()->get('user_id')
213
-			);
214
-		});
215
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
216
-
217
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
218
-			return new \OC\Preview\Watcher(
219
-				$c->getAppDataDir('preview')
220
-			);
221
-		});
222
-
223
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
224
-			$view = new View();
225
-			$util = new Encryption\Util(
226
-				$view,
227
-				$c->getUserManager(),
228
-				$c->getGroupManager(),
229
-				$c->getConfig()
230
-			);
231
-			return new Encryption\Manager(
232
-				$c->getConfig(),
233
-				$c->getLogger(),
234
-				$c->getL10N('core'),
235
-				new View(),
236
-				$util,
237
-				new ArrayCache()
238
-			);
239
-		});
240
-		$this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class);
241
-
242
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
243
-			$util = new Encryption\Util(
244
-				new View(),
245
-				$c->getUserManager(),
246
-				$c->getGroupManager(),
247
-				$c->getConfig()
248
-			);
249
-			return new Encryption\File(
250
-				$util,
251
-				$c->getRootFolder(),
252
-				$c->getShareManager()
253
-			);
254
-		});
255
-
256
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
257
-			$view = new View();
258
-			$util = new Encryption\Util(
259
-				$view,
260
-				$c->getUserManager(),
261
-				$c->getGroupManager(),
262
-				$c->getConfig()
263
-			);
264
-
265
-			return new Encryption\Keys\Storage($view, $util);
266
-		});
267
-		$this->registerService('TagMapper', function (Server $c) {
268
-			return new TagMapper($c->getDatabaseConnection());
269
-		});
270
-
271
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
272
-			$tagMapper = $c->query('TagMapper');
273
-			return new TagManager($tagMapper, $c->getUserSession());
274
-		});
275
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
276
-
277
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
278
-			$config = $c->getConfig();
279
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
280
-			return new $factoryClass($this);
281
-		});
282
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
283
-			return $c->query('SystemTagManagerFactory')->getManager();
284
-		});
285
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
286
-
287
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
288
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
289
-		});
290
-		$this->registerService('RootFolder', function (Server $c) {
291
-			$manager = \OC\Files\Filesystem::getMountManager(null);
292
-			$view = new View();
293
-			$root = new Root(
294
-				$manager,
295
-				$view,
296
-				null,
297
-				$c->getUserMountCache(),
298
-				$this->getLogger(),
299
-				$this->getUserManager()
300
-			);
301
-			$connector = new HookConnector($root, $view);
302
-			$connector->viewToNode();
303
-
304
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
305
-			$previewConnector->connectWatcher();
306
-
307
-			return $root;
308
-		});
309
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
310
-
311
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
312
-			return new LazyRoot(function () use ($c) {
313
-				return $c->query('RootFolder');
314
-			});
315
-		});
316
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
317
-
318
-		$this->registerService(\OC\User\Manager::class, function (Server $c) {
319
-			return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher());
320
-		});
321
-		$this->registerAlias('UserManager', \OC\User\Manager::class);
322
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
323
-
324
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
325
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
326
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
327
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
328
-			});
329
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
330
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
331
-			});
332
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
333
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
334
-			});
335
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
336
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
337
-			});
338
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
339
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
340
-			});
341
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
342
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
343
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
344
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
345
-			});
346
-			return $groupManager;
347
-		});
348
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
349
-
350
-		$this->registerService(Store::class, function (Server $c) {
351
-			$session = $c->getSession();
352
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
353
-				$tokenProvider = $c->query(IProvider::class);
354
-			} else {
355
-				$tokenProvider = null;
356
-			}
357
-			$logger = $c->getLogger();
358
-			return new Store($session, $logger, $tokenProvider);
359
-		});
360
-		$this->registerAlias(IStore::class, Store::class);
361
-		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
362
-			$dbConnection = $c->getDatabaseConnection();
363
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
364
-		});
365
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
366
-
367
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
368
-			$manager = $c->getUserManager();
369
-			$session = new \OC\Session\Memory('');
370
-			$timeFactory = new TimeFactory();
371
-			// Token providers might require a working database. This code
372
-			// might however be called when ownCloud is not yet setup.
373
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
374
-				$defaultTokenProvider = $c->query(IProvider::class);
375
-			} else {
376
-				$defaultTokenProvider = null;
377
-			}
378
-
379
-			$dispatcher = $c->getEventDispatcher();
380
-
381
-			$userSession = new \OC\User\Session(
382
-				$manager,
383
-				$session,
384
-				$timeFactory,
385
-				$defaultTokenProvider,
386
-				$c->getConfig(),
387
-				$c->getSecureRandom(),
388
-				$c->getLockdownManager(),
389
-				$c->getLogger(),
390
-				$c->query(IEventDispatcher::class)
391
-			);
392
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
393
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
394
-			});
395
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
396
-				/** @var $user \OC\User\User */
397
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
398
-			});
399
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
400
-				/** @var $user \OC\User\User */
401
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
402
-				$dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
403
-			});
404
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
405
-				/** @var $user \OC\User\User */
406
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
407
-			});
408
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
409
-				/** @var $user \OC\User\User */
410
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
411
-			});
412
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
413
-				/** @var $user \OC\User\User */
414
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
415
-			});
416
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
417
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
418
-			});
419
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
420
-				/** @var $user \OC\User\User */
421
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin));
422
-			});
423
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
424
-				/** @var $user \OC\User\User */
425
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
426
-			});
427
-			$userSession->listen('\OC\User', 'logout', function () {
428
-				\OC_Hook::emit('OC_User', 'logout', array());
429
-			});
430
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
431
-				/** @var $user \OC\User\User */
432
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
433
-			});
434
-			return $userSession;
435
-		});
436
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
437
-		$this->registerAlias('UserSession', \OC\User\Session::class);
438
-
439
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
440
-
441
-		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
442
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
443
-
444
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
445
-			return new \OC\AllConfig(
446
-				$c->getSystemConfig()
447
-			);
448
-		});
449
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
450
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
451
-
452
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
453
-			return new \OC\SystemConfig($config);
454
-		});
455
-		$this->registerAlias('SystemConfig', \OC\SystemConfig::class);
456
-
457
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
458
-			return new \OC\AppConfig($c->getDatabaseConnection());
459
-		});
460
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
461
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
462
-
463
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
464
-			return new \OC\L10N\Factory(
465
-				$c->getConfig(),
466
-				$c->getRequest(),
467
-				$c->getUserSession(),
468
-				\OC::$SERVERROOT
469
-			);
470
-		});
471
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
472
-
473
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
474
-			$config = $c->getConfig();
475
-			$cacheFactory = $c->getMemCacheFactory();
476
-			$request = $c->getRequest();
477
-			return new \OC\URLGenerator(
478
-				$config,
479
-				$cacheFactory,
480
-				$request
481
-			);
482
-		});
483
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
484
-
485
-		$this->registerAlias('AppFetcher', AppFetcher::class);
486
-		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
487
-
488
-		$this->registerService(\OCP\ICache::class, function ($c) {
489
-			return new Cache\File();
490
-		});
491
-		$this->registerAlias('UserCache', \OCP\ICache::class);
492
-
493
-		$this->registerService(Factory::class, function (Server $c) {
494
-
495
-			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
496
-				ArrayCache::class,
497
-				ArrayCache::class,
498
-				ArrayCache::class
499
-			);
500
-			$config = $c->getConfig();
501
-
502
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
503
-				$v = \OC_App::getAppVersions();
504
-				$v['core'] = implode(',', \OC_Util::getVersion());
505
-				$version = implode(',', $v);
506
-				$instanceId = \OC_Util::getInstanceId();
507
-				$path = \OC::$SERVERROOT;
508
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
509
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
510
-					$config->getSystemValue('memcache.local', null),
511
-					$config->getSystemValue('memcache.distributed', null),
512
-					$config->getSystemValue('memcache.locking', null)
513
-				);
514
-			}
515
-			return $arrayCacheFactory;
516
-
517
-		});
518
-		$this->registerAlias('MemCacheFactory', Factory::class);
519
-		$this->registerAlias(ICacheFactory::class, Factory::class);
520
-
521
-		$this->registerService('RedisFactory', function (Server $c) {
522
-			$systemConfig = $c->getSystemConfig();
523
-			return new RedisFactory($systemConfig);
524
-		});
525
-
526
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
527
-			return new \OC\Activity\Manager(
528
-				$c->getRequest(),
529
-				$c->getUserSession(),
530
-				$c->getConfig(),
531
-				$c->query(IValidator::class)
532
-			);
533
-		});
534
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
535
-
536
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
537
-			return new \OC\Activity\EventMerger(
538
-				$c->getL10N('lib')
539
-			);
540
-		});
541
-		$this->registerAlias(IValidator::class, Validator::class);
542
-
543
-		$this->registerService(AvatarManager::class, function(Server $c) {
544
-			return new AvatarManager(
545
-				$c->query(\OC\User\Manager::class),
546
-				$c->getAppDataDir('avatar'),
547
-				$c->getL10N('lib'),
548
-				$c->getLogger(),
549
-				$c->getConfig()
550
-			);
551
-		});
552
-		$this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class);
553
-		$this->registerAlias('AvatarManager', AvatarManager::class);
554
-
555
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
556
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
557
-
558
-		$this->registerService(\OC\Log::class, function (Server $c) {
559
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
560
-			$factory = new LogFactory($c, $this->getSystemConfig());
561
-			$logger = $factory->get($logType);
562
-			$registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
563
-
564
-			return new Log($logger, $this->getSystemConfig(), null, $registry);
565
-		});
566
-		$this->registerAlias(\OCP\ILogger::class, \OC\Log::class);
567
-		$this->registerAlias('Logger', \OC\Log::class);
568
-
569
-		$this->registerService(ILogFactory::class, function (Server $c) {
570
-			return new LogFactory($c, $this->getSystemConfig());
571
-		});
572
-
573
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
574
-			$config = $c->getConfig();
575
-			return new \OC\BackgroundJob\JobList(
576
-				$c->getDatabaseConnection(),
577
-				$config,
578
-				new TimeFactory()
579
-			);
580
-		});
581
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
582
-
583
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
584
-			$cacheFactory = $c->getMemCacheFactory();
585
-			$logger = $c->getLogger();
586
-			if ($cacheFactory->isLocalCacheAvailable()) {
587
-				$router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
588
-			} else {
589
-				$router = new \OC\Route\Router($logger);
590
-			}
591
-			return $router;
592
-		});
593
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
594
-
595
-		$this->registerService(\OCP\ISearch::class, function ($c) {
596
-			return new Search();
597
-		});
598
-		$this->registerAlias('Search', \OCP\ISearch::class);
599
-
600
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
601
-			return new \OC\Security\RateLimiting\Backend\MemoryCache(
602
-				$this->getMemCacheFactory(),
603
-				new \OC\AppFramework\Utility\TimeFactory()
604
-			);
605
-		});
606
-
607
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
608
-			return new SecureRandom();
609
-		});
610
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
611
-
612
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
613
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
614
-		});
615
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
616
-
617
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
618
-			return new Hasher($c->getConfig());
619
-		});
620
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
621
-
622
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
623
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
624
-		});
625
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
626
-
627
-		$this->registerService(IDBConnection::class, function (Server $c) {
628
-			$systemConfig = $c->getSystemConfig();
629
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
630
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
631
-			if (!$factory->isValidType($type)) {
632
-				throw new \OC\DatabaseException('Invalid database type');
633
-			}
634
-			$connectionParams = $factory->createConnectionParams();
635
-			$connection = $factory->getConnection($type, $connectionParams);
636
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
637
-			return $connection;
638
-		});
639
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
640
-
641
-
642
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
643
-			$user = \OC_User::getUser();
644
-			$uid = $user ? $user : null;
645
-			return new ClientService(
646
-				$c->getConfig(),
647
-				new \OC\Security\CertificateManager(
648
-					$uid,
649
-					new View(),
650
-					$c->getConfig(),
651
-					$c->getLogger(),
652
-					$c->getSecureRandom()
653
-				)
654
-			);
655
-		});
656
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
657
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
658
-			$eventLogger = new EventLogger();
659
-			if ($c->getSystemConfig()->getValue('debug', false)) {
660
-				// In debug mode, module is being activated by default
661
-				$eventLogger->activate();
662
-			}
663
-			return $eventLogger;
664
-		});
665
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
666
-
667
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
668
-			$queryLogger = new QueryLogger();
669
-			if ($c->getSystemConfig()->getValue('debug', false)) {
670
-				// In debug mode, module is being activated by default
671
-				$queryLogger->activate();
672
-			}
673
-			return $queryLogger;
674
-		});
675
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
676
-
677
-		$this->registerService(TempManager::class, function (Server $c) {
678
-			return new TempManager(
679
-				$c->getLogger(),
680
-				$c->getConfig()
681
-			);
682
-		});
683
-		$this->registerAlias('TempManager', TempManager::class);
684
-		$this->registerAlias(ITempManager::class, TempManager::class);
685
-
686
-		$this->registerService(AppManager::class, function (Server $c) {
687
-			return new \OC\App\AppManager(
688
-				$c->getUserSession(),
689
-				$c->query(\OC\AppConfig::class),
690
-				$c->getGroupManager(),
691
-				$c->getMemCacheFactory(),
692
-				$c->getEventDispatcher(),
693
-				$c->getLogger()
694
-			);
695
-		});
696
-		$this->registerAlias('AppManager', AppManager::class);
697
-		$this->registerAlias(IAppManager::class, AppManager::class);
698
-
699
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
700
-			return new DateTimeZone(
701
-				$c->getConfig(),
702
-				$c->getSession()
703
-			);
704
-		});
705
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
706
-
707
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
708
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
709
-
710
-			return new DateTimeFormatter(
711
-				$c->getDateTimeZone()->getTimeZone(),
712
-				$c->getL10N('lib', $language)
713
-			);
714
-		});
715
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
716
-
717
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
718
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
719
-			$listener = new UserMountCacheListener($mountCache);
720
-			$listener->listen($c->getUserManager());
721
-			return $mountCache;
722
-		});
723
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
724
-
725
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
726
-			$loader = \OC\Files\Filesystem::getLoader();
727
-			$mountCache = $c->query('UserMountCache');
728
-			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
729
-
730
-			// builtin providers
731
-
732
-			$config = $c->getConfig();
733
-			$manager->registerProvider(new CacheMountProvider($config));
734
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
735
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
736
-
737
-			return $manager;
738
-		});
739
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
740
-
741
-		$this->registerService('IniWrapper', function ($c) {
742
-			return new IniGetWrapper();
743
-		});
744
-		$this->registerService('AsyncCommandBus', function (Server $c) {
745
-			$busClass = $c->getConfig()->getSystemValue('commandbus');
746
-			if ($busClass) {
747
-				list($app, $class) = explode('::', $busClass, 2);
748
-				if ($c->getAppManager()->isInstalled($app)) {
749
-					\OC_App::loadApp($app);
750
-					return $c->query($class);
751
-				} else {
752
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
753
-				}
754
-			} else {
755
-				$jobList = $c->getJobList();
756
-				return new CronBus($jobList);
757
-			}
758
-		});
759
-		$this->registerService('TrustedDomainHelper', function ($c) {
760
-			return new TrustedDomainHelper($this->getConfig());
761
-		});
762
-		$this->registerService(Throttler::class, function (Server $c) {
763
-			return new Throttler(
764
-				$c->getDatabaseConnection(),
765
-				new TimeFactory(),
766
-				$c->getLogger(),
767
-				$c->getConfig()
768
-			);
769
-		});
770
-		$this->registerAlias('Throttler', Throttler::class);
771
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
772
-			// IConfig and IAppManager requires a working database. This code
773
-			// might however be called when ownCloud is not yet setup.
774
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
775
-				$config = $c->getConfig();
776
-				$appManager = $c->getAppManager();
777
-			} else {
778
-				$config = null;
779
-				$appManager = null;
780
-			}
781
-
782
-			return new Checker(
783
-				new EnvironmentHelper(),
784
-				new FileAccessHelper(),
785
-				new AppLocator(),
786
-				$config,
787
-				$c->getMemCacheFactory(),
788
-				$appManager,
789
-				$c->getTempManager(),
790
-				$c->getMimeTypeDetector()
791
-			);
792
-		});
793
-		$this->registerService(\OCP\IRequest::class, function ($c) {
794
-			if (isset($this['urlParams'])) {
795
-				$urlParams = $this['urlParams'];
796
-			} else {
797
-				$urlParams = [];
798
-			}
799
-
800
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
801
-				&& in_array('fakeinput', stream_get_wrappers())
802
-			) {
803
-				$stream = 'fakeinput://data';
804
-			} else {
805
-				$stream = 'php://input';
806
-			}
807
-
808
-			return new Request(
809
-				[
810
-					'get' => $_GET,
811
-					'post' => $_POST,
812
-					'files' => $_FILES,
813
-					'server' => $_SERVER,
814
-					'env' => $_ENV,
815
-					'cookies' => $_COOKIE,
816
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
817
-						? $_SERVER['REQUEST_METHOD']
818
-						: '',
819
-					'urlParams' => $urlParams,
820
-				],
821
-				$this->getSecureRandom(),
822
-				$this->getConfig(),
823
-				$this->getCsrfTokenManager(),
824
-				$stream
825
-			);
826
-		});
827
-		$this->registerAlias('Request', \OCP\IRequest::class);
828
-
829
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
830
-			return new Mailer(
831
-				$c->getConfig(),
832
-				$c->getLogger(),
833
-				$c->query(Defaults::class),
834
-				$c->getURLGenerator(),
835
-				$c->getL10N('lib')
836
-			);
837
-		});
838
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
839
-
840
-		$this->registerService('LDAPProvider', function (Server $c) {
841
-			$config = $c->getConfig();
842
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
843
-			if (is_null($factoryClass)) {
844
-				throw new \Exception('ldapProviderFactory not set');
845
-			}
846
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
847
-			$factory = new $factoryClass($this);
848
-			return $factory->getLDAPProvider();
849
-		});
850
-		$this->registerService(ILockingProvider::class, function (Server $c) {
851
-			$ini = $c->getIniWrapper();
852
-			$config = $c->getConfig();
853
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
854
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
855
-				/** @var \OC\Memcache\Factory $memcacheFactory */
856
-				$memcacheFactory = $c->getMemCacheFactory();
857
-				$memcache = $memcacheFactory->createLocking('lock');
858
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
859
-					return new MemcacheLockingProvider($memcache, $ttl);
860
-				}
861
-				return new DBLockingProvider(
862
-					$c->getDatabaseConnection(),
863
-					$c->getLogger(),
864
-					new TimeFactory(),
865
-					$ttl,
866
-					!\OC::$CLI
867
-				);
868
-			}
869
-			return new NoopLockingProvider();
870
-		});
871
-		$this->registerAlias('LockingProvider', ILockingProvider::class);
872
-
873
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
874
-			return new \OC\Files\Mount\Manager();
875
-		});
876
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
877
-
878
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
879
-			return new \OC\Files\Type\Detection(
880
-				$c->getURLGenerator(),
881
-				\OC::$configDir,
882
-				\OC::$SERVERROOT . '/resources/config/'
883
-			);
884
-		});
885
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
886
-
887
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
888
-			return new \OC\Files\Type\Loader(
889
-				$c->getDatabaseConnection()
890
-			);
891
-		});
892
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
893
-		$this->registerService(BundleFetcher::class, function () {
894
-			return new BundleFetcher($this->getL10N('lib'));
895
-		});
896
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
897
-			return new Manager(
898
-				$c->query(IValidator::class),
899
-				$c->getLogger()
900
-			);
901
-		});
902
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
903
-
904
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
905
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
906
-			$manager->registerCapability(function () use ($c) {
907
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
908
-			});
909
-			$manager->registerCapability(function () use ($c) {
910
-				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
911
-			});
912
-			return $manager;
913
-		});
914
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
915
-
916
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
917
-			$config = $c->getConfig();
918
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
919
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
920
-			$factory = new $factoryClass($this);
921
-			$manager = $factory->getManager();
922
-
923
-			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
924
-				$manager = $c->getUserManager();
925
-				$user = $manager->get($id);
926
-				if(is_null($user)) {
927
-					$l = $c->getL10N('core');
928
-					$displayName = $l->t('Unknown user');
929
-				} else {
930
-					$displayName = $user->getDisplayName();
931
-				}
932
-				return $displayName;
933
-			});
934
-
935
-			return $manager;
936
-		});
937
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
938
-
939
-		$this->registerService('ThemingDefaults', function (Server $c) {
940
-			/*
172
+    /** @var string */
173
+    private $webRoot;
174
+
175
+    /**
176
+     * @param string $webRoot
177
+     * @param \OC\Config $config
178
+     */
179
+    public function __construct($webRoot, \OC\Config $config) {
180
+        parent::__construct();
181
+        $this->webRoot = $webRoot;
182
+
183
+        // To find out if we are running from CLI or not
184
+        $this->registerParameter('isCLI', \OC::$CLI);
185
+
186
+        $this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
187
+            return $c;
188
+        });
189
+
190
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
191
+        $this->registerAlias('CalendarManager', \OC\Calendar\Manager::class);
192
+
193
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
194
+        $this->registerAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
195
+
196
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
197
+        $this->registerAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
198
+
199
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
200
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
201
+
202
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
203
+
204
+
205
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
206
+            return new PreviewManager(
207
+                $c->getConfig(),
208
+                $c->getRootFolder(),
209
+                $c->getAppDataDir('preview'),
210
+                $c->getEventDispatcher(),
211
+                $c->getGeneratorHelper(),
212
+                $c->getSession()->get('user_id')
213
+            );
214
+        });
215
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
216
+
217
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
218
+            return new \OC\Preview\Watcher(
219
+                $c->getAppDataDir('preview')
220
+            );
221
+        });
222
+
223
+        $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
224
+            $view = new View();
225
+            $util = new Encryption\Util(
226
+                $view,
227
+                $c->getUserManager(),
228
+                $c->getGroupManager(),
229
+                $c->getConfig()
230
+            );
231
+            return new Encryption\Manager(
232
+                $c->getConfig(),
233
+                $c->getLogger(),
234
+                $c->getL10N('core'),
235
+                new View(),
236
+                $util,
237
+                new ArrayCache()
238
+            );
239
+        });
240
+        $this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class);
241
+
242
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
243
+            $util = new Encryption\Util(
244
+                new View(),
245
+                $c->getUserManager(),
246
+                $c->getGroupManager(),
247
+                $c->getConfig()
248
+            );
249
+            return new Encryption\File(
250
+                $util,
251
+                $c->getRootFolder(),
252
+                $c->getShareManager()
253
+            );
254
+        });
255
+
256
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
257
+            $view = new View();
258
+            $util = new Encryption\Util(
259
+                $view,
260
+                $c->getUserManager(),
261
+                $c->getGroupManager(),
262
+                $c->getConfig()
263
+            );
264
+
265
+            return new Encryption\Keys\Storage($view, $util);
266
+        });
267
+        $this->registerService('TagMapper', function (Server $c) {
268
+            return new TagMapper($c->getDatabaseConnection());
269
+        });
270
+
271
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
272
+            $tagMapper = $c->query('TagMapper');
273
+            return new TagManager($tagMapper, $c->getUserSession());
274
+        });
275
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
276
+
277
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
278
+            $config = $c->getConfig();
279
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
280
+            return new $factoryClass($this);
281
+        });
282
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
283
+            return $c->query('SystemTagManagerFactory')->getManager();
284
+        });
285
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
286
+
287
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
288
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
289
+        });
290
+        $this->registerService('RootFolder', function (Server $c) {
291
+            $manager = \OC\Files\Filesystem::getMountManager(null);
292
+            $view = new View();
293
+            $root = new Root(
294
+                $manager,
295
+                $view,
296
+                null,
297
+                $c->getUserMountCache(),
298
+                $this->getLogger(),
299
+                $this->getUserManager()
300
+            );
301
+            $connector = new HookConnector($root, $view);
302
+            $connector->viewToNode();
303
+
304
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
305
+            $previewConnector->connectWatcher();
306
+
307
+            return $root;
308
+        });
309
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
310
+
311
+        $this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
312
+            return new LazyRoot(function () use ($c) {
313
+                return $c->query('RootFolder');
314
+            });
315
+        });
316
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
317
+
318
+        $this->registerService(\OC\User\Manager::class, function (Server $c) {
319
+            return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher());
320
+        });
321
+        $this->registerAlias('UserManager', \OC\User\Manager::class);
322
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
323
+
324
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
325
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
326
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
327
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
328
+            });
329
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
330
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
331
+            });
332
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
333
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
334
+            });
335
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
336
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
337
+            });
338
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
339
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
340
+            });
341
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
342
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
343
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
344
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
345
+            });
346
+            return $groupManager;
347
+        });
348
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
349
+
350
+        $this->registerService(Store::class, function (Server $c) {
351
+            $session = $c->getSession();
352
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
353
+                $tokenProvider = $c->query(IProvider::class);
354
+            } else {
355
+                $tokenProvider = null;
356
+            }
357
+            $logger = $c->getLogger();
358
+            return new Store($session, $logger, $tokenProvider);
359
+        });
360
+        $this->registerAlias(IStore::class, Store::class);
361
+        $this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
362
+            $dbConnection = $c->getDatabaseConnection();
363
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
364
+        });
365
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
366
+
367
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
368
+            $manager = $c->getUserManager();
369
+            $session = new \OC\Session\Memory('');
370
+            $timeFactory = new TimeFactory();
371
+            // Token providers might require a working database. This code
372
+            // might however be called when ownCloud is not yet setup.
373
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
374
+                $defaultTokenProvider = $c->query(IProvider::class);
375
+            } else {
376
+                $defaultTokenProvider = null;
377
+            }
378
+
379
+            $dispatcher = $c->getEventDispatcher();
380
+
381
+            $userSession = new \OC\User\Session(
382
+                $manager,
383
+                $session,
384
+                $timeFactory,
385
+                $defaultTokenProvider,
386
+                $c->getConfig(),
387
+                $c->getSecureRandom(),
388
+                $c->getLockdownManager(),
389
+                $c->getLogger(),
390
+                $c->query(IEventDispatcher::class)
391
+            );
392
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
393
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
394
+            });
395
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
396
+                /** @var $user \OC\User\User */
397
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
398
+            });
399
+            $userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
400
+                /** @var $user \OC\User\User */
401
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
402
+                $dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
403
+            });
404
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
405
+                /** @var $user \OC\User\User */
406
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
407
+            });
408
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
409
+                /** @var $user \OC\User\User */
410
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
411
+            });
412
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
413
+                /** @var $user \OC\User\User */
414
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
415
+            });
416
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
417
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
418
+            });
419
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
420
+                /** @var $user \OC\User\User */
421
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin));
422
+            });
423
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
424
+                /** @var $user \OC\User\User */
425
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
426
+            });
427
+            $userSession->listen('\OC\User', 'logout', function () {
428
+                \OC_Hook::emit('OC_User', 'logout', array());
429
+            });
430
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
431
+                /** @var $user \OC\User\User */
432
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
433
+            });
434
+            return $userSession;
435
+        });
436
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
437
+        $this->registerAlias('UserSession', \OC\User\Session::class);
438
+
439
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
440
+
441
+        $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
442
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
443
+
444
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
445
+            return new \OC\AllConfig(
446
+                $c->getSystemConfig()
447
+            );
448
+        });
449
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
450
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
451
+
452
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
453
+            return new \OC\SystemConfig($config);
454
+        });
455
+        $this->registerAlias('SystemConfig', \OC\SystemConfig::class);
456
+
457
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
458
+            return new \OC\AppConfig($c->getDatabaseConnection());
459
+        });
460
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
461
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
462
+
463
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
464
+            return new \OC\L10N\Factory(
465
+                $c->getConfig(),
466
+                $c->getRequest(),
467
+                $c->getUserSession(),
468
+                \OC::$SERVERROOT
469
+            );
470
+        });
471
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
472
+
473
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
474
+            $config = $c->getConfig();
475
+            $cacheFactory = $c->getMemCacheFactory();
476
+            $request = $c->getRequest();
477
+            return new \OC\URLGenerator(
478
+                $config,
479
+                $cacheFactory,
480
+                $request
481
+            );
482
+        });
483
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
484
+
485
+        $this->registerAlias('AppFetcher', AppFetcher::class);
486
+        $this->registerAlias('CategoryFetcher', CategoryFetcher::class);
487
+
488
+        $this->registerService(\OCP\ICache::class, function ($c) {
489
+            return new Cache\File();
490
+        });
491
+        $this->registerAlias('UserCache', \OCP\ICache::class);
492
+
493
+        $this->registerService(Factory::class, function (Server $c) {
494
+
495
+            $arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
496
+                ArrayCache::class,
497
+                ArrayCache::class,
498
+                ArrayCache::class
499
+            );
500
+            $config = $c->getConfig();
501
+
502
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
503
+                $v = \OC_App::getAppVersions();
504
+                $v['core'] = implode(',', \OC_Util::getVersion());
505
+                $version = implode(',', $v);
506
+                $instanceId = \OC_Util::getInstanceId();
507
+                $path = \OC::$SERVERROOT;
508
+                $prefix = md5($instanceId . '-' . $version . '-' . $path);
509
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
510
+                    $config->getSystemValue('memcache.local', null),
511
+                    $config->getSystemValue('memcache.distributed', null),
512
+                    $config->getSystemValue('memcache.locking', null)
513
+                );
514
+            }
515
+            return $arrayCacheFactory;
516
+
517
+        });
518
+        $this->registerAlias('MemCacheFactory', Factory::class);
519
+        $this->registerAlias(ICacheFactory::class, Factory::class);
520
+
521
+        $this->registerService('RedisFactory', function (Server $c) {
522
+            $systemConfig = $c->getSystemConfig();
523
+            return new RedisFactory($systemConfig);
524
+        });
525
+
526
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
527
+            return new \OC\Activity\Manager(
528
+                $c->getRequest(),
529
+                $c->getUserSession(),
530
+                $c->getConfig(),
531
+                $c->query(IValidator::class)
532
+            );
533
+        });
534
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
535
+
536
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
537
+            return new \OC\Activity\EventMerger(
538
+                $c->getL10N('lib')
539
+            );
540
+        });
541
+        $this->registerAlias(IValidator::class, Validator::class);
542
+
543
+        $this->registerService(AvatarManager::class, function(Server $c) {
544
+            return new AvatarManager(
545
+                $c->query(\OC\User\Manager::class),
546
+                $c->getAppDataDir('avatar'),
547
+                $c->getL10N('lib'),
548
+                $c->getLogger(),
549
+                $c->getConfig()
550
+            );
551
+        });
552
+        $this->registerAlias(\OCP\IAvatarManager::class, AvatarManager::class);
553
+        $this->registerAlias('AvatarManager', AvatarManager::class);
554
+
555
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
556
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
557
+
558
+        $this->registerService(\OC\Log::class, function (Server $c) {
559
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
560
+            $factory = new LogFactory($c, $this->getSystemConfig());
561
+            $logger = $factory->get($logType);
562
+            $registry = $c->query(\OCP\Support\CrashReport\IRegistry::class);
563
+
564
+            return new Log($logger, $this->getSystemConfig(), null, $registry);
565
+        });
566
+        $this->registerAlias(\OCP\ILogger::class, \OC\Log::class);
567
+        $this->registerAlias('Logger', \OC\Log::class);
568
+
569
+        $this->registerService(ILogFactory::class, function (Server $c) {
570
+            return new LogFactory($c, $this->getSystemConfig());
571
+        });
572
+
573
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
574
+            $config = $c->getConfig();
575
+            return new \OC\BackgroundJob\JobList(
576
+                $c->getDatabaseConnection(),
577
+                $config,
578
+                new TimeFactory()
579
+            );
580
+        });
581
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
582
+
583
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
584
+            $cacheFactory = $c->getMemCacheFactory();
585
+            $logger = $c->getLogger();
586
+            if ($cacheFactory->isLocalCacheAvailable()) {
587
+                $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
588
+            } else {
589
+                $router = new \OC\Route\Router($logger);
590
+            }
591
+            return $router;
592
+        });
593
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
594
+
595
+        $this->registerService(\OCP\ISearch::class, function ($c) {
596
+            return new Search();
597
+        });
598
+        $this->registerAlias('Search', \OCP\ISearch::class);
599
+
600
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
601
+            return new \OC\Security\RateLimiting\Backend\MemoryCache(
602
+                $this->getMemCacheFactory(),
603
+                new \OC\AppFramework\Utility\TimeFactory()
604
+            );
605
+        });
606
+
607
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
608
+            return new SecureRandom();
609
+        });
610
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
611
+
612
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
613
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
614
+        });
615
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
616
+
617
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
618
+            return new Hasher($c->getConfig());
619
+        });
620
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
621
+
622
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
623
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
624
+        });
625
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
626
+
627
+        $this->registerService(IDBConnection::class, function (Server $c) {
628
+            $systemConfig = $c->getSystemConfig();
629
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
630
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
631
+            if (!$factory->isValidType($type)) {
632
+                throw new \OC\DatabaseException('Invalid database type');
633
+            }
634
+            $connectionParams = $factory->createConnectionParams();
635
+            $connection = $factory->getConnection($type, $connectionParams);
636
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
637
+            return $connection;
638
+        });
639
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
640
+
641
+
642
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
643
+            $user = \OC_User::getUser();
644
+            $uid = $user ? $user : null;
645
+            return new ClientService(
646
+                $c->getConfig(),
647
+                new \OC\Security\CertificateManager(
648
+                    $uid,
649
+                    new View(),
650
+                    $c->getConfig(),
651
+                    $c->getLogger(),
652
+                    $c->getSecureRandom()
653
+                )
654
+            );
655
+        });
656
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
657
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
658
+            $eventLogger = new EventLogger();
659
+            if ($c->getSystemConfig()->getValue('debug', false)) {
660
+                // In debug mode, module is being activated by default
661
+                $eventLogger->activate();
662
+            }
663
+            return $eventLogger;
664
+        });
665
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
666
+
667
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
668
+            $queryLogger = new QueryLogger();
669
+            if ($c->getSystemConfig()->getValue('debug', false)) {
670
+                // In debug mode, module is being activated by default
671
+                $queryLogger->activate();
672
+            }
673
+            return $queryLogger;
674
+        });
675
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
676
+
677
+        $this->registerService(TempManager::class, function (Server $c) {
678
+            return new TempManager(
679
+                $c->getLogger(),
680
+                $c->getConfig()
681
+            );
682
+        });
683
+        $this->registerAlias('TempManager', TempManager::class);
684
+        $this->registerAlias(ITempManager::class, TempManager::class);
685
+
686
+        $this->registerService(AppManager::class, function (Server $c) {
687
+            return new \OC\App\AppManager(
688
+                $c->getUserSession(),
689
+                $c->query(\OC\AppConfig::class),
690
+                $c->getGroupManager(),
691
+                $c->getMemCacheFactory(),
692
+                $c->getEventDispatcher(),
693
+                $c->getLogger()
694
+            );
695
+        });
696
+        $this->registerAlias('AppManager', AppManager::class);
697
+        $this->registerAlias(IAppManager::class, AppManager::class);
698
+
699
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
700
+            return new DateTimeZone(
701
+                $c->getConfig(),
702
+                $c->getSession()
703
+            );
704
+        });
705
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
706
+
707
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
708
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
709
+
710
+            return new DateTimeFormatter(
711
+                $c->getDateTimeZone()->getTimeZone(),
712
+                $c->getL10N('lib', $language)
713
+            );
714
+        });
715
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
716
+
717
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
718
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
719
+            $listener = new UserMountCacheListener($mountCache);
720
+            $listener->listen($c->getUserManager());
721
+            return $mountCache;
722
+        });
723
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
724
+
725
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
726
+            $loader = \OC\Files\Filesystem::getLoader();
727
+            $mountCache = $c->query('UserMountCache');
728
+            $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
729
+
730
+            // builtin providers
731
+
732
+            $config = $c->getConfig();
733
+            $manager->registerProvider(new CacheMountProvider($config));
734
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
735
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
736
+
737
+            return $manager;
738
+        });
739
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
740
+
741
+        $this->registerService('IniWrapper', function ($c) {
742
+            return new IniGetWrapper();
743
+        });
744
+        $this->registerService('AsyncCommandBus', function (Server $c) {
745
+            $busClass = $c->getConfig()->getSystemValue('commandbus');
746
+            if ($busClass) {
747
+                list($app, $class) = explode('::', $busClass, 2);
748
+                if ($c->getAppManager()->isInstalled($app)) {
749
+                    \OC_App::loadApp($app);
750
+                    return $c->query($class);
751
+                } else {
752
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
753
+                }
754
+            } else {
755
+                $jobList = $c->getJobList();
756
+                return new CronBus($jobList);
757
+            }
758
+        });
759
+        $this->registerService('TrustedDomainHelper', function ($c) {
760
+            return new TrustedDomainHelper($this->getConfig());
761
+        });
762
+        $this->registerService(Throttler::class, function (Server $c) {
763
+            return new Throttler(
764
+                $c->getDatabaseConnection(),
765
+                new TimeFactory(),
766
+                $c->getLogger(),
767
+                $c->getConfig()
768
+            );
769
+        });
770
+        $this->registerAlias('Throttler', Throttler::class);
771
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
772
+            // IConfig and IAppManager requires a working database. This code
773
+            // might however be called when ownCloud is not yet setup.
774
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
775
+                $config = $c->getConfig();
776
+                $appManager = $c->getAppManager();
777
+            } else {
778
+                $config = null;
779
+                $appManager = null;
780
+            }
781
+
782
+            return new Checker(
783
+                new EnvironmentHelper(),
784
+                new FileAccessHelper(),
785
+                new AppLocator(),
786
+                $config,
787
+                $c->getMemCacheFactory(),
788
+                $appManager,
789
+                $c->getTempManager(),
790
+                $c->getMimeTypeDetector()
791
+            );
792
+        });
793
+        $this->registerService(\OCP\IRequest::class, function ($c) {
794
+            if (isset($this['urlParams'])) {
795
+                $urlParams = $this['urlParams'];
796
+            } else {
797
+                $urlParams = [];
798
+            }
799
+
800
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
801
+                && in_array('fakeinput', stream_get_wrappers())
802
+            ) {
803
+                $stream = 'fakeinput://data';
804
+            } else {
805
+                $stream = 'php://input';
806
+            }
807
+
808
+            return new Request(
809
+                [
810
+                    'get' => $_GET,
811
+                    'post' => $_POST,
812
+                    'files' => $_FILES,
813
+                    'server' => $_SERVER,
814
+                    'env' => $_ENV,
815
+                    'cookies' => $_COOKIE,
816
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
817
+                        ? $_SERVER['REQUEST_METHOD']
818
+                        : '',
819
+                    'urlParams' => $urlParams,
820
+                ],
821
+                $this->getSecureRandom(),
822
+                $this->getConfig(),
823
+                $this->getCsrfTokenManager(),
824
+                $stream
825
+            );
826
+        });
827
+        $this->registerAlias('Request', \OCP\IRequest::class);
828
+
829
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
830
+            return new Mailer(
831
+                $c->getConfig(),
832
+                $c->getLogger(),
833
+                $c->query(Defaults::class),
834
+                $c->getURLGenerator(),
835
+                $c->getL10N('lib')
836
+            );
837
+        });
838
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
839
+
840
+        $this->registerService('LDAPProvider', function (Server $c) {
841
+            $config = $c->getConfig();
842
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
843
+            if (is_null($factoryClass)) {
844
+                throw new \Exception('ldapProviderFactory not set');
845
+            }
846
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
847
+            $factory = new $factoryClass($this);
848
+            return $factory->getLDAPProvider();
849
+        });
850
+        $this->registerService(ILockingProvider::class, function (Server $c) {
851
+            $ini = $c->getIniWrapper();
852
+            $config = $c->getConfig();
853
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
854
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
855
+                /** @var \OC\Memcache\Factory $memcacheFactory */
856
+                $memcacheFactory = $c->getMemCacheFactory();
857
+                $memcache = $memcacheFactory->createLocking('lock');
858
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
859
+                    return new MemcacheLockingProvider($memcache, $ttl);
860
+                }
861
+                return new DBLockingProvider(
862
+                    $c->getDatabaseConnection(),
863
+                    $c->getLogger(),
864
+                    new TimeFactory(),
865
+                    $ttl,
866
+                    !\OC::$CLI
867
+                );
868
+            }
869
+            return new NoopLockingProvider();
870
+        });
871
+        $this->registerAlias('LockingProvider', ILockingProvider::class);
872
+
873
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
874
+            return new \OC\Files\Mount\Manager();
875
+        });
876
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
877
+
878
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
879
+            return new \OC\Files\Type\Detection(
880
+                $c->getURLGenerator(),
881
+                \OC::$configDir,
882
+                \OC::$SERVERROOT . '/resources/config/'
883
+            );
884
+        });
885
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
886
+
887
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
888
+            return new \OC\Files\Type\Loader(
889
+                $c->getDatabaseConnection()
890
+            );
891
+        });
892
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
893
+        $this->registerService(BundleFetcher::class, function () {
894
+            return new BundleFetcher($this->getL10N('lib'));
895
+        });
896
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
897
+            return new Manager(
898
+                $c->query(IValidator::class),
899
+                $c->getLogger()
900
+            );
901
+        });
902
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
903
+
904
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
905
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
906
+            $manager->registerCapability(function () use ($c) {
907
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
908
+            });
909
+            $manager->registerCapability(function () use ($c) {
910
+                return $c->query(\OC\Security\Bruteforce\Capabilities::class);
911
+            });
912
+            return $manager;
913
+        });
914
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
915
+
916
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
917
+            $config = $c->getConfig();
918
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
919
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
920
+            $factory = new $factoryClass($this);
921
+            $manager = $factory->getManager();
922
+
923
+            $manager->registerDisplayNameResolver('user', function($id) use ($c) {
924
+                $manager = $c->getUserManager();
925
+                $user = $manager->get($id);
926
+                if(is_null($user)) {
927
+                    $l = $c->getL10N('core');
928
+                    $displayName = $l->t('Unknown user');
929
+                } else {
930
+                    $displayName = $user->getDisplayName();
931
+                }
932
+                return $displayName;
933
+            });
934
+
935
+            return $manager;
936
+        });
937
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
938
+
939
+        $this->registerService('ThemingDefaults', function (Server $c) {
940
+            /*
941 941
 			 * Dark magic for autoloader.
942 942
 			 * If we do a class_exists it will try to load the class which will
943 943
 			 * make composer cache the result. Resulting in errors when enabling
944 944
 			 * the theming app.
945 945
 			 */
946
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
947
-			if (isset($prefixes['OCA\\Theming\\'])) {
948
-				$classExists = true;
949
-			} else {
950
-				$classExists = false;
951
-			}
952
-
953
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
954
-				return new ThemingDefaults(
955
-					$c->getConfig(),
956
-					$c->getL10N('theming'),
957
-					$c->getURLGenerator(),
958
-					$c->getMemCacheFactory(),
959
-					new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
960
-					new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
961
-					$c->getAppManager(),
962
-					$c->getNavigationManager()
963
-				);
964
-			}
965
-			return new \OC_Defaults();
966
-		});
967
-		$this->registerService(SCSSCacher::class, function (Server $c) {
968
-			return new SCSSCacher(
969
-				$c->getLogger(),
970
-				$c->query(\OC\Files\AppData\Factory::class),
971
-				$c->getURLGenerator(),
972
-				$c->getConfig(),
973
-				$c->getThemingDefaults(),
974
-				\OC::$SERVERROOT,
975
-				$this->getMemCacheFactory(),
976
-				$c->query(IconsCacher::class),
977
-				new TimeFactory()
978
-			);
979
-		});
980
-		$this->registerService(JSCombiner::class, function (Server $c) {
981
-			return new JSCombiner(
982
-				$c->getAppDataDir('js'),
983
-				$c->getURLGenerator(),
984
-				$this->getMemCacheFactory(),
985
-				$c->getSystemConfig(),
986
-				$c->getLogger()
987
-			);
988
-		});
989
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
990
-		$this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
991
-		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
992
-
993
-		$this->registerService('CryptoWrapper', function (Server $c) {
994
-			// FIXME: Instantiiated here due to cyclic dependency
995
-			$request = new Request(
996
-				[
997
-					'get' => $_GET,
998
-					'post' => $_POST,
999
-					'files' => $_FILES,
1000
-					'server' => $_SERVER,
1001
-					'env' => $_ENV,
1002
-					'cookies' => $_COOKIE,
1003
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1004
-						? $_SERVER['REQUEST_METHOD']
1005
-						: null,
1006
-				],
1007
-				$c->getSecureRandom(),
1008
-				$c->getConfig()
1009
-			);
1010
-
1011
-			return new CryptoWrapper(
1012
-				$c->getConfig(),
1013
-				$c->getCrypto(),
1014
-				$c->getSecureRandom(),
1015
-				$request
1016
-			);
1017
-		});
1018
-		$this->registerService(CsrfTokenManager::class, function (Server $c) {
1019
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1020
-
1021
-			return new CsrfTokenManager(
1022
-				$tokenGenerator,
1023
-				$c->query(SessionStorage::class)
1024
-			);
1025
-		});
1026
-		$this->registerAlias('CsrfTokenManager', CsrfTokenManager::class);
1027
-		$this->registerService(SessionStorage::class, function (Server $c) {
1028
-			return new SessionStorage($c->getSession());
1029
-		});
1030
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class);
1031
-		$this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class);
1032
-
1033
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1034
-			return new ContentSecurityPolicyNonceManager(
1035
-				$c->getCsrfTokenManager(),
1036
-				$c->getRequest()
1037
-			);
1038
-		});
1039
-
1040
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1041
-			$config = $c->getConfig();
1042
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1043
-			/** @var \OCP\Share\IProviderFactory $factory */
1044
-			$factory = new $factoryClass($this);
1045
-
1046
-			$manager = new \OC\Share20\Manager(
1047
-				$c->getLogger(),
1048
-				$c->getConfig(),
1049
-				$c->getSecureRandom(),
1050
-				$c->getHasher(),
1051
-				$c->getMountManager(),
1052
-				$c->getGroupManager(),
1053
-				$c->getL10N('lib'),
1054
-				$c->getL10NFactory(),
1055
-				$factory,
1056
-				$c->getUserManager(),
1057
-				$c->getLazyRootFolder(),
1058
-				$c->getEventDispatcher(),
1059
-				$c->getMailer(),
1060
-				$c->getURLGenerator(),
1061
-				$c->getThemingDefaults()
1062
-			);
1063
-
1064
-			return $manager;
1065
-		});
1066
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1067
-
1068
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1069
-			$instance = new Collaboration\Collaborators\Search($c);
1070
-
1071
-			// register default plugins
1072
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1073
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1074
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1075
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1076
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1077
-
1078
-			return $instance;
1079
-		});
1080
-		$this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1081
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1082
-
1083
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1084
-
1085
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1086
-
1087
-		$this->registerService('SettingsManager', function (Server $c) {
1088
-			$manager = new \OC\Settings\Manager(
1089
-				$c->getLogger(),
1090
-				$c->getL10NFactory(),
1091
-				$c->getURLGenerator(),
1092
-				$c
1093
-			);
1094
-			return $manager;
1095
-		});
1096
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1097
-			return new \OC\Files\AppData\Factory(
1098
-				$c->getRootFolder(),
1099
-				$c->getSystemConfig()
1100
-			);
1101
-		});
1102
-
1103
-		$this->registerService('LockdownManager', function (Server $c) {
1104
-			return new LockdownManager(function () use ($c) {
1105
-				return $c->getSession();
1106
-			});
1107
-		});
1108
-
1109
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1110
-			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1111
-		});
1112
-
1113
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1114
-			return new CloudIdManager();
1115
-		});
1116
-
1117
-		$this->registerService(IConfig::class, function (Server $c) {
1118
-			return new GlobalScale\Config($c->getConfig());
1119
-		});
1120
-
1121
-		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1122
-			return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1123
-		});
1124
-
1125
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1126
-			return new CloudFederationFactory();
1127
-		});
1128
-
1129
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1130
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1131
-
1132
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1133
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1134
-
1135
-		$this->registerService(Defaults::class, function (Server $c) {
1136
-			return new Defaults(
1137
-				$c->getThemingDefaults()
1138
-			);
1139
-		});
1140
-		$this->registerAlias('Defaults', \OCP\Defaults::class);
1141
-
1142
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1143
-			return $c->query(\OCP\IUserSession::class)->getSession();
1144
-		});
1145
-
1146
-		$this->registerService(IShareHelper::class, function (Server $c) {
1147
-			return new ShareHelper(
1148
-				$c->query(\OCP\Share\IManager::class)
1149
-			);
1150
-		});
1151
-
1152
-		$this->registerService(Installer::class, function(Server $c) {
1153
-			return new Installer(
1154
-				$c->getAppFetcher(),
1155
-				$c->getHTTPClientService(),
1156
-				$c->getTempManager(),
1157
-				$c->getLogger(),
1158
-				$c->getConfig()
1159
-			);
1160
-		});
1161
-
1162
-		$this->registerService(IApiFactory::class, function(Server $c) {
1163
-			return new ApiFactory($c->getHTTPClientService());
1164
-		});
1165
-
1166
-		$this->registerService(IInstanceFactory::class, function(Server $c) {
1167
-			$memcacheFactory = $c->getMemCacheFactory();
1168
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1169
-		});
1170
-
1171
-		$this->registerService(IContactsStore::class, function(Server $c) {
1172
-			return new ContactsStore(
1173
-				$c->getContactsManager(),
1174
-				$c->getConfig(),
1175
-				$c->getUserManager(),
1176
-				$c->getGroupManager()
1177
-			);
1178
-		});
1179
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1180
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1181
-
1182
-		$this->registerService(IStorageFactory::class, function() {
1183
-			return new StorageFactory();
1184
-		});
1185
-
1186
-		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1187
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1188
-
1189
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) {
1190
-			return new \OC\Security\IdentityProof\Manager(
1191
-				$c->query(\OC\Files\AppData\Factory::class),
1192
-				$c->getCrypto(),
1193
-				$c->getConfig()
1194
-			);
1195
-		});
1196
-
1197
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1198
-
1199
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1200
-
1201
-		$this->connectDispatcher();
1202
-	}
1203
-
1204
-	/**
1205
-	 * @return \OCP\Calendar\IManager
1206
-	 */
1207
-	public function getCalendarManager() {
1208
-		return $this->query('CalendarManager');
1209
-	}
1210
-
1211
-	/**
1212
-	 * @return \OCP\Calendar\Resource\IManager
1213
-	 */
1214
-	public function getCalendarResourceBackendManager() {
1215
-		return $this->query('CalendarResourceBackendManager');
1216
-	}
1217
-
1218
-	/**
1219
-	 * @return \OCP\Calendar\Room\IManager
1220
-	 */
1221
-	public function getCalendarRoomBackendManager() {
1222
-		return $this->query('CalendarRoomBackendManager');
1223
-	}
1224
-
1225
-	private function connectDispatcher() {
1226
-		$dispatcher = $this->getEventDispatcher();
1227
-
1228
-		// Delete avatar on user deletion
1229
-		$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1230
-			$logger = $this->getLogger();
1231
-			$manager = $this->getAvatarManager();
1232
-			/** @var IUser $user */
1233
-			$user = $e->getSubject();
1234
-
1235
-			try {
1236
-				$avatar = $manager->getAvatar($user->getUID());
1237
-				$avatar->remove();
1238
-			} catch (NotFoundException $e) {
1239
-				// no avatar to remove
1240
-			} catch (\Exception $e) {
1241
-				// Ignore exceptions
1242
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1243
-			}
1244
-		});
1245
-
1246
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1247
-			$manager = $this->getAvatarManager();
1248
-			/** @var IUser $user */
1249
-			$user = $e->getSubject();
1250
-			$feature = $e->getArgument('feature');
1251
-			$oldValue = $e->getArgument('oldValue');
1252
-			$value = $e->getArgument('value');
1253
-
1254
-			// We only change the avatar on display name changes
1255
-			if ($feature !== 'displayName') {
1256
-				return;
1257
-			}
1258
-
1259
-			try {
1260
-				$avatar = $manager->getAvatar($user->getUID());
1261
-				$avatar->userChanged($feature, $oldValue, $value);
1262
-			} catch (NotFoundException $e) {
1263
-				// no avatar to remove
1264
-			}
1265
-		});
1266
-	}
1267
-
1268
-	/**
1269
-	 * @return \OCP\Contacts\IManager
1270
-	 */
1271
-	public function getContactsManager() {
1272
-		return $this->query('ContactsManager');
1273
-	}
1274
-
1275
-	/**
1276
-	 * @return \OC\Encryption\Manager
1277
-	 */
1278
-	public function getEncryptionManager() {
1279
-		return $this->query('EncryptionManager');
1280
-	}
1281
-
1282
-	/**
1283
-	 * @return \OC\Encryption\File
1284
-	 */
1285
-	public function getEncryptionFilesHelper() {
1286
-		return $this->query('EncryptionFileHelper');
1287
-	}
1288
-
1289
-	/**
1290
-	 * @return \OCP\Encryption\Keys\IStorage
1291
-	 */
1292
-	public function getEncryptionKeyStorage() {
1293
-		return $this->query('EncryptionKeyStorage');
1294
-	}
1295
-
1296
-	/**
1297
-	 * The current request object holding all information about the request
1298
-	 * currently being processed is returned from this method.
1299
-	 * In case the current execution was not initiated by a web request null is returned
1300
-	 *
1301
-	 * @return \OCP\IRequest
1302
-	 */
1303
-	public function getRequest() {
1304
-		return $this->query('Request');
1305
-	}
1306
-
1307
-	/**
1308
-	 * Returns the preview manager which can create preview images for a given file
1309
-	 *
1310
-	 * @return \OCP\IPreview
1311
-	 */
1312
-	public function getPreviewManager() {
1313
-		return $this->query('PreviewManager');
1314
-	}
1315
-
1316
-	/**
1317
-	 * Returns the tag manager which can get and set tags for different object types
1318
-	 *
1319
-	 * @see \OCP\ITagManager::load()
1320
-	 * @return \OCP\ITagManager
1321
-	 */
1322
-	public function getTagManager() {
1323
-		return $this->query('TagManager');
1324
-	}
1325
-
1326
-	/**
1327
-	 * Returns the system-tag manager
1328
-	 *
1329
-	 * @return \OCP\SystemTag\ISystemTagManager
1330
-	 *
1331
-	 * @since 9.0.0
1332
-	 */
1333
-	public function getSystemTagManager() {
1334
-		return $this->query('SystemTagManager');
1335
-	}
1336
-
1337
-	/**
1338
-	 * Returns the system-tag object mapper
1339
-	 *
1340
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1341
-	 *
1342
-	 * @since 9.0.0
1343
-	 */
1344
-	public function getSystemTagObjectMapper() {
1345
-		return $this->query('SystemTagObjectMapper');
1346
-	}
1347
-
1348
-	/**
1349
-	 * Returns the avatar manager, used for avatar functionality
1350
-	 *
1351
-	 * @return \OCP\IAvatarManager
1352
-	 */
1353
-	public function getAvatarManager() {
1354
-		return $this->query('AvatarManager');
1355
-	}
1356
-
1357
-	/**
1358
-	 * Returns the root folder of ownCloud's data directory
1359
-	 *
1360
-	 * @return \OCP\Files\IRootFolder
1361
-	 */
1362
-	public function getRootFolder() {
1363
-		return $this->query('LazyRootFolder');
1364
-	}
1365
-
1366
-	/**
1367
-	 * Returns the root folder of ownCloud's data directory
1368
-	 * This is the lazy variant so this gets only initialized once it
1369
-	 * is actually used.
1370
-	 *
1371
-	 * @return \OCP\Files\IRootFolder
1372
-	 */
1373
-	public function getLazyRootFolder() {
1374
-		return $this->query('LazyRootFolder');
1375
-	}
1376
-
1377
-	/**
1378
-	 * Returns a view to ownCloud's files folder
1379
-	 *
1380
-	 * @param string $userId user ID
1381
-	 * @return \OCP\Files\Folder|null
1382
-	 */
1383
-	public function getUserFolder($userId = null) {
1384
-		if ($userId === null) {
1385
-			$user = $this->getUserSession()->getUser();
1386
-			if (!$user) {
1387
-				return null;
1388
-			}
1389
-			$userId = $user->getUID();
1390
-		}
1391
-		$root = $this->getRootFolder();
1392
-		return $root->getUserFolder($userId);
1393
-	}
1394
-
1395
-	/**
1396
-	 * Returns an app-specific view in ownClouds data directory
1397
-	 *
1398
-	 * @return \OCP\Files\Folder
1399
-	 * @deprecated since 9.2.0 use IAppData
1400
-	 */
1401
-	public function getAppFolder() {
1402
-		$dir = '/' . \OC_App::getCurrentApp();
1403
-		$root = $this->getRootFolder();
1404
-		if (!$root->nodeExists($dir)) {
1405
-			$folder = $root->newFolder($dir);
1406
-		} else {
1407
-			$folder = $root->get($dir);
1408
-		}
1409
-		return $folder;
1410
-	}
1411
-
1412
-	/**
1413
-	 * @return \OC\User\Manager
1414
-	 */
1415
-	public function getUserManager() {
1416
-		return $this->query('UserManager');
1417
-	}
1418
-
1419
-	/**
1420
-	 * @return \OC\Group\Manager
1421
-	 */
1422
-	public function getGroupManager() {
1423
-		return $this->query('GroupManager');
1424
-	}
1425
-
1426
-	/**
1427
-	 * @return \OC\User\Session
1428
-	 */
1429
-	public function getUserSession() {
1430
-		return $this->query('UserSession');
1431
-	}
1432
-
1433
-	/**
1434
-	 * @return \OCP\ISession
1435
-	 */
1436
-	public function getSession() {
1437
-		return $this->query('UserSession')->getSession();
1438
-	}
1439
-
1440
-	/**
1441
-	 * @param \OCP\ISession $session
1442
-	 */
1443
-	public function setSession(\OCP\ISession $session) {
1444
-		$this->query(SessionStorage::class)->setSession($session);
1445
-		$this->query('UserSession')->setSession($session);
1446
-		$this->query(Store::class)->setSession($session);
1447
-	}
1448
-
1449
-	/**
1450
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1451
-	 */
1452
-	public function getTwoFactorAuthManager() {
1453
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1454
-	}
1455
-
1456
-	/**
1457
-	 * @return \OC\NavigationManager
1458
-	 */
1459
-	public function getNavigationManager() {
1460
-		return $this->query('NavigationManager');
1461
-	}
1462
-
1463
-	/**
1464
-	 * @return \OCP\IConfig
1465
-	 */
1466
-	public function getConfig() {
1467
-		return $this->query('AllConfig');
1468
-	}
1469
-
1470
-	/**
1471
-	 * @return \OC\SystemConfig
1472
-	 */
1473
-	public function getSystemConfig() {
1474
-		return $this->query('SystemConfig');
1475
-	}
1476
-
1477
-	/**
1478
-	 * Returns the app config manager
1479
-	 *
1480
-	 * @return \OCP\IAppConfig
1481
-	 */
1482
-	public function getAppConfig() {
1483
-		return $this->query('AppConfig');
1484
-	}
1485
-
1486
-	/**
1487
-	 * @return \OCP\L10N\IFactory
1488
-	 */
1489
-	public function getL10NFactory() {
1490
-		return $this->query('L10NFactory');
1491
-	}
1492
-
1493
-	/**
1494
-	 * get an L10N instance
1495
-	 *
1496
-	 * @param string $app appid
1497
-	 * @param string $lang
1498
-	 * @return IL10N
1499
-	 */
1500
-	public function getL10N($app, $lang = null) {
1501
-		return $this->getL10NFactory()->get($app, $lang);
1502
-	}
1503
-
1504
-	/**
1505
-	 * @return \OCP\IURLGenerator
1506
-	 */
1507
-	public function getURLGenerator() {
1508
-		return $this->query('URLGenerator');
1509
-	}
1510
-
1511
-	/**
1512
-	 * @return AppFetcher
1513
-	 */
1514
-	public function getAppFetcher() {
1515
-		return $this->query(AppFetcher::class);
1516
-	}
1517
-
1518
-	/**
1519
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1520
-	 * getMemCacheFactory() instead.
1521
-	 *
1522
-	 * @return \OCP\ICache
1523
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1524
-	 */
1525
-	public function getCache() {
1526
-		return $this->query('UserCache');
1527
-	}
1528
-
1529
-	/**
1530
-	 * Returns an \OCP\CacheFactory instance
1531
-	 *
1532
-	 * @return \OCP\ICacheFactory
1533
-	 */
1534
-	public function getMemCacheFactory() {
1535
-		return $this->query('MemCacheFactory');
1536
-	}
1537
-
1538
-	/**
1539
-	 * Returns an \OC\RedisFactory instance
1540
-	 *
1541
-	 * @return \OC\RedisFactory
1542
-	 */
1543
-	public function getGetRedisFactory() {
1544
-		return $this->query('RedisFactory');
1545
-	}
1546
-
1547
-
1548
-	/**
1549
-	 * Returns the current session
1550
-	 *
1551
-	 * @return \OCP\IDBConnection
1552
-	 */
1553
-	public function getDatabaseConnection() {
1554
-		return $this->query('DatabaseConnection');
1555
-	}
1556
-
1557
-	/**
1558
-	 * Returns the activity manager
1559
-	 *
1560
-	 * @return \OCP\Activity\IManager
1561
-	 */
1562
-	public function getActivityManager() {
1563
-		return $this->query('ActivityManager');
1564
-	}
1565
-
1566
-	/**
1567
-	 * Returns an job list for controlling background jobs
1568
-	 *
1569
-	 * @return \OCP\BackgroundJob\IJobList
1570
-	 */
1571
-	public function getJobList() {
1572
-		return $this->query('JobList');
1573
-	}
1574
-
1575
-	/**
1576
-	 * Returns a logger instance
1577
-	 *
1578
-	 * @return \OCP\ILogger
1579
-	 */
1580
-	public function getLogger() {
1581
-		return $this->query('Logger');
1582
-	}
1583
-
1584
-	/**
1585
-	 * @return ILogFactory
1586
-	 * @throws \OCP\AppFramework\QueryException
1587
-	 */
1588
-	public function getLogFactory() {
1589
-		return $this->query(ILogFactory::class);
1590
-	}
1591
-
1592
-	/**
1593
-	 * Returns a router for generating and matching urls
1594
-	 *
1595
-	 * @return \OCP\Route\IRouter
1596
-	 */
1597
-	public function getRouter() {
1598
-		return $this->query('Router');
1599
-	}
1600
-
1601
-	/**
1602
-	 * Returns a search instance
1603
-	 *
1604
-	 * @return \OCP\ISearch
1605
-	 */
1606
-	public function getSearch() {
1607
-		return $this->query('Search');
1608
-	}
1609
-
1610
-	/**
1611
-	 * Returns a SecureRandom instance
1612
-	 *
1613
-	 * @return \OCP\Security\ISecureRandom
1614
-	 */
1615
-	public function getSecureRandom() {
1616
-		return $this->query('SecureRandom');
1617
-	}
1618
-
1619
-	/**
1620
-	 * Returns a Crypto instance
1621
-	 *
1622
-	 * @return \OCP\Security\ICrypto
1623
-	 */
1624
-	public function getCrypto() {
1625
-		return $this->query('Crypto');
1626
-	}
1627
-
1628
-	/**
1629
-	 * Returns a Hasher instance
1630
-	 *
1631
-	 * @return \OCP\Security\IHasher
1632
-	 */
1633
-	public function getHasher() {
1634
-		return $this->query('Hasher');
1635
-	}
1636
-
1637
-	/**
1638
-	 * Returns a CredentialsManager instance
1639
-	 *
1640
-	 * @return \OCP\Security\ICredentialsManager
1641
-	 */
1642
-	public function getCredentialsManager() {
1643
-		return $this->query('CredentialsManager');
1644
-	}
1645
-
1646
-	/**
1647
-	 * Get the certificate manager for the user
1648
-	 *
1649
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1650
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1651
-	 */
1652
-	public function getCertificateManager($userId = '') {
1653
-		if ($userId === '') {
1654
-			$userSession = $this->getUserSession();
1655
-			$user = $userSession->getUser();
1656
-			if (is_null($user)) {
1657
-				return null;
1658
-			}
1659
-			$userId = $user->getUID();
1660
-		}
1661
-		return new CertificateManager(
1662
-			$userId,
1663
-			new View(),
1664
-			$this->getConfig(),
1665
-			$this->getLogger(),
1666
-			$this->getSecureRandom()
1667
-		);
1668
-	}
1669
-
1670
-	/**
1671
-	 * Returns an instance of the HTTP client service
1672
-	 *
1673
-	 * @return \OCP\Http\Client\IClientService
1674
-	 */
1675
-	public function getHTTPClientService() {
1676
-		return $this->query('HttpClientService');
1677
-	}
1678
-
1679
-	/**
1680
-	 * Create a new event source
1681
-	 *
1682
-	 * @return \OCP\IEventSource
1683
-	 */
1684
-	public function createEventSource() {
1685
-		return new \OC_EventSource();
1686
-	}
1687
-
1688
-	/**
1689
-	 * Get the active event logger
1690
-	 *
1691
-	 * The returned logger only logs data when debug mode is enabled
1692
-	 *
1693
-	 * @return \OCP\Diagnostics\IEventLogger
1694
-	 */
1695
-	public function getEventLogger() {
1696
-		return $this->query('EventLogger');
1697
-	}
1698
-
1699
-	/**
1700
-	 * Get the active query logger
1701
-	 *
1702
-	 * The returned logger only logs data when debug mode is enabled
1703
-	 *
1704
-	 * @return \OCP\Diagnostics\IQueryLogger
1705
-	 */
1706
-	public function getQueryLogger() {
1707
-		return $this->query('QueryLogger');
1708
-	}
1709
-
1710
-	/**
1711
-	 * Get the manager for temporary files and folders
1712
-	 *
1713
-	 * @return \OCP\ITempManager
1714
-	 */
1715
-	public function getTempManager() {
1716
-		return $this->query('TempManager');
1717
-	}
1718
-
1719
-	/**
1720
-	 * Get the app manager
1721
-	 *
1722
-	 * @return \OCP\App\IAppManager
1723
-	 */
1724
-	public function getAppManager() {
1725
-		return $this->query('AppManager');
1726
-	}
1727
-
1728
-	/**
1729
-	 * Creates a new mailer
1730
-	 *
1731
-	 * @return \OCP\Mail\IMailer
1732
-	 */
1733
-	public function getMailer() {
1734
-		return $this->query('Mailer');
1735
-	}
1736
-
1737
-	/**
1738
-	 * Get the webroot
1739
-	 *
1740
-	 * @return string
1741
-	 */
1742
-	public function getWebRoot() {
1743
-		return $this->webRoot;
1744
-	}
1745
-
1746
-	/**
1747
-	 * @return \OC\OCSClient
1748
-	 */
1749
-	public function getOcsClient() {
1750
-		return $this->query('OcsClient');
1751
-	}
1752
-
1753
-	/**
1754
-	 * @return \OCP\IDateTimeZone
1755
-	 */
1756
-	public function getDateTimeZone() {
1757
-		return $this->query('DateTimeZone');
1758
-	}
1759
-
1760
-	/**
1761
-	 * @return \OCP\IDateTimeFormatter
1762
-	 */
1763
-	public function getDateTimeFormatter() {
1764
-		return $this->query('DateTimeFormatter');
1765
-	}
1766
-
1767
-	/**
1768
-	 * @return \OCP\Files\Config\IMountProviderCollection
1769
-	 */
1770
-	public function getMountProviderCollection() {
1771
-		return $this->query('MountConfigManager');
1772
-	}
1773
-
1774
-	/**
1775
-	 * Get the IniWrapper
1776
-	 *
1777
-	 * @return IniGetWrapper
1778
-	 */
1779
-	public function getIniWrapper() {
1780
-		return $this->query('IniWrapper');
1781
-	}
1782
-
1783
-	/**
1784
-	 * @return \OCP\Command\IBus
1785
-	 */
1786
-	public function getCommandBus() {
1787
-		return $this->query('AsyncCommandBus');
1788
-	}
1789
-
1790
-	/**
1791
-	 * Get the trusted domain helper
1792
-	 *
1793
-	 * @return TrustedDomainHelper
1794
-	 */
1795
-	public function getTrustedDomainHelper() {
1796
-		return $this->query('TrustedDomainHelper');
1797
-	}
1798
-
1799
-	/**
1800
-	 * Get the locking provider
1801
-	 *
1802
-	 * @return \OCP\Lock\ILockingProvider
1803
-	 * @since 8.1.0
1804
-	 */
1805
-	public function getLockingProvider() {
1806
-		return $this->query('LockingProvider');
1807
-	}
1808
-
1809
-	/**
1810
-	 * @return \OCP\Files\Mount\IMountManager
1811
-	 **/
1812
-	function getMountManager() {
1813
-		return $this->query('MountManager');
1814
-	}
1815
-
1816
-	/** @return \OCP\Files\Config\IUserMountCache */
1817
-	function getUserMountCache() {
1818
-		return $this->query('UserMountCache');
1819
-	}
1820
-
1821
-	/**
1822
-	 * Get the MimeTypeDetector
1823
-	 *
1824
-	 * @return \OCP\Files\IMimeTypeDetector
1825
-	 */
1826
-	public function getMimeTypeDetector() {
1827
-		return $this->query('MimeTypeDetector');
1828
-	}
1829
-
1830
-	/**
1831
-	 * Get the MimeTypeLoader
1832
-	 *
1833
-	 * @return \OCP\Files\IMimeTypeLoader
1834
-	 */
1835
-	public function getMimeTypeLoader() {
1836
-		return $this->query('MimeTypeLoader');
1837
-	}
1838
-
1839
-	/**
1840
-	 * Get the manager of all the capabilities
1841
-	 *
1842
-	 * @return \OC\CapabilitiesManager
1843
-	 */
1844
-	public function getCapabilitiesManager() {
1845
-		return $this->query('CapabilitiesManager');
1846
-	}
1847
-
1848
-	/**
1849
-	 * Get the EventDispatcher
1850
-	 *
1851
-	 * @return EventDispatcherInterface
1852
-	 * @since 8.2.0
1853
-	 */
1854
-	public function getEventDispatcher() {
1855
-		return $this->query(\OC\EventDispatcher\SymfonyAdapter::class);
1856
-	}
1857
-
1858
-	/**
1859
-	 * Get the Notification Manager
1860
-	 *
1861
-	 * @return \OCP\Notification\IManager
1862
-	 * @since 8.2.0
1863
-	 */
1864
-	public function getNotificationManager() {
1865
-		return $this->query('NotificationManager');
1866
-	}
1867
-
1868
-	/**
1869
-	 * @return \OCP\Comments\ICommentsManager
1870
-	 */
1871
-	public function getCommentsManager() {
1872
-		return $this->query('CommentsManager');
1873
-	}
1874
-
1875
-	/**
1876
-	 * @return \OCA\Theming\ThemingDefaults
1877
-	 */
1878
-	public function getThemingDefaults() {
1879
-		return $this->query('ThemingDefaults');
1880
-	}
1881
-
1882
-	/**
1883
-	 * @return \OC\IntegrityCheck\Checker
1884
-	 */
1885
-	public function getIntegrityCodeChecker() {
1886
-		return $this->query('IntegrityCodeChecker');
1887
-	}
1888
-
1889
-	/**
1890
-	 * @return \OC\Session\CryptoWrapper
1891
-	 */
1892
-	public function getSessionCryptoWrapper() {
1893
-		return $this->query('CryptoWrapper');
1894
-	}
1895
-
1896
-	/**
1897
-	 * @return CsrfTokenManager
1898
-	 */
1899
-	public function getCsrfTokenManager() {
1900
-		return $this->query(CsrfTokenManager::class);
1901
-	}
1902
-
1903
-	/**
1904
-	 * @return Throttler
1905
-	 */
1906
-	public function getBruteForceThrottler() {
1907
-		return $this->query('Throttler');
1908
-	}
1909
-
1910
-	/**
1911
-	 * @return IContentSecurityPolicyManager
1912
-	 */
1913
-	public function getContentSecurityPolicyManager() {
1914
-		return $this->query('ContentSecurityPolicyManager');
1915
-	}
1916
-
1917
-	/**
1918
-	 * @return ContentSecurityPolicyNonceManager
1919
-	 */
1920
-	public function getContentSecurityPolicyNonceManager() {
1921
-		return $this->query('ContentSecurityPolicyNonceManager');
1922
-	}
1923
-
1924
-	/**
1925
-	 * Not a public API as of 8.2, wait for 9.0
1926
-	 *
1927
-	 * @return \OCA\Files_External\Service\BackendService
1928
-	 */
1929
-	public function getStoragesBackendService() {
1930
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1931
-	}
1932
-
1933
-	/**
1934
-	 * Not a public API as of 8.2, wait for 9.0
1935
-	 *
1936
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1937
-	 */
1938
-	public function getGlobalStoragesService() {
1939
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1940
-	}
1941
-
1942
-	/**
1943
-	 * Not a public API as of 8.2, wait for 9.0
1944
-	 *
1945
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1946
-	 */
1947
-	public function getUserGlobalStoragesService() {
1948
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1949
-	}
1950
-
1951
-	/**
1952
-	 * Not a public API as of 8.2, wait for 9.0
1953
-	 *
1954
-	 * @return \OCA\Files_External\Service\UserStoragesService
1955
-	 */
1956
-	public function getUserStoragesService() {
1957
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1958
-	}
1959
-
1960
-	/**
1961
-	 * @return \OCP\Share\IManager
1962
-	 */
1963
-	public function getShareManager() {
1964
-		return $this->query('ShareManager');
1965
-	}
1966
-
1967
-	/**
1968
-	 * @return \OCP\Collaboration\Collaborators\ISearch
1969
-	 */
1970
-	public function getCollaboratorSearch() {
1971
-		return $this->query('CollaboratorSearch');
1972
-	}
1973
-
1974
-	/**
1975
-	 * @return \OCP\Collaboration\AutoComplete\IManager
1976
-	 */
1977
-	public function getAutoCompleteManager(){
1978
-		return $this->query(IManager::class);
1979
-	}
1980
-
1981
-	/**
1982
-	 * Returns the LDAP Provider
1983
-	 *
1984
-	 * @return \OCP\LDAP\ILDAPProvider
1985
-	 */
1986
-	public function getLDAPProvider() {
1987
-		return $this->query('LDAPProvider');
1988
-	}
1989
-
1990
-	/**
1991
-	 * @return \OCP\Settings\IManager
1992
-	 */
1993
-	public function getSettingsManager() {
1994
-		return $this->query('SettingsManager');
1995
-	}
1996
-
1997
-	/**
1998
-	 * @return \OCP\Files\IAppData
1999
-	 */
2000
-	public function getAppDataDir($app) {
2001
-		/** @var \OC\Files\AppData\Factory $factory */
2002
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
2003
-		return $factory->get($app);
2004
-	}
2005
-
2006
-	/**
2007
-	 * @return \OCP\Lockdown\ILockdownManager
2008
-	 */
2009
-	public function getLockdownManager() {
2010
-		return $this->query('LockdownManager');
2011
-	}
2012
-
2013
-	/**
2014
-	 * @return \OCP\Federation\ICloudIdManager
2015
-	 */
2016
-	public function getCloudIdManager() {
2017
-		return $this->query(ICloudIdManager::class);
2018
-	}
2019
-
2020
-	/**
2021
-	 * @return \OCP\GlobalScale\IConfig
2022
-	 */
2023
-	public function getGlobalScaleConfig() {
2024
-		return $this->query(IConfig::class);
2025
-	}
2026
-
2027
-	/**
2028
-	 * @return \OCP\Federation\ICloudFederationProviderManager
2029
-	 */
2030
-	public function getCloudFederationProviderManager() {
2031
-		return $this->query(ICloudFederationProviderManager::class);
2032
-	}
2033
-
2034
-	/**
2035
-	 * @return \OCP\Remote\Api\IApiFactory
2036
-	 */
2037
-	public function getRemoteApiFactory() {
2038
-		return $this->query(IApiFactory::class);
2039
-	}
2040
-
2041
-	/**
2042
-	 * @return \OCP\Federation\ICloudFederationFactory
2043
-	 */
2044
-	public function getCloudFederationFactory() {
2045
-		return $this->query(ICloudFederationFactory::class);
2046
-	}
2047
-
2048
-	/**
2049
-	 * @return \OCP\Remote\IInstanceFactory
2050
-	 */
2051
-	public function getRemoteInstanceFactory() {
2052
-		return $this->query(IInstanceFactory::class);
2053
-	}
2054
-
2055
-	/**
2056
-	 * @return IStorageFactory
2057
-	 */
2058
-	public function getStorageFactory() {
2059
-		return $this->query(IStorageFactory::class);
2060
-	}
2061
-
2062
-	/**
2063
-	 * Get the Preview GeneratorHelper
2064
-	 *
2065
-	 * @return GeneratorHelper
2066
-	 * @since 17.0.0
2067
-	 */
2068
-	public function getGeneratorHelper() {
2069
-		return $this->query(\OC\Preview\GeneratorHelper::class);
2070
-	}
946
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
947
+            if (isset($prefixes['OCA\\Theming\\'])) {
948
+                $classExists = true;
949
+            } else {
950
+                $classExists = false;
951
+            }
952
+
953
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
954
+                return new ThemingDefaults(
955
+                    $c->getConfig(),
956
+                    $c->getL10N('theming'),
957
+                    $c->getURLGenerator(),
958
+                    $c->getMemCacheFactory(),
959
+                    new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
960
+                    new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
961
+                    $c->getAppManager(),
962
+                    $c->getNavigationManager()
963
+                );
964
+            }
965
+            return new \OC_Defaults();
966
+        });
967
+        $this->registerService(SCSSCacher::class, function (Server $c) {
968
+            return new SCSSCacher(
969
+                $c->getLogger(),
970
+                $c->query(\OC\Files\AppData\Factory::class),
971
+                $c->getURLGenerator(),
972
+                $c->getConfig(),
973
+                $c->getThemingDefaults(),
974
+                \OC::$SERVERROOT,
975
+                $this->getMemCacheFactory(),
976
+                $c->query(IconsCacher::class),
977
+                new TimeFactory()
978
+            );
979
+        });
980
+        $this->registerService(JSCombiner::class, function (Server $c) {
981
+            return new JSCombiner(
982
+                $c->getAppDataDir('js'),
983
+                $c->getURLGenerator(),
984
+                $this->getMemCacheFactory(),
985
+                $c->getSystemConfig(),
986
+                $c->getLogger()
987
+            );
988
+        });
989
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
990
+        $this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
991
+        $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
992
+
993
+        $this->registerService('CryptoWrapper', function (Server $c) {
994
+            // FIXME: Instantiiated here due to cyclic dependency
995
+            $request = new Request(
996
+                [
997
+                    'get' => $_GET,
998
+                    'post' => $_POST,
999
+                    'files' => $_FILES,
1000
+                    'server' => $_SERVER,
1001
+                    'env' => $_ENV,
1002
+                    'cookies' => $_COOKIE,
1003
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1004
+                        ? $_SERVER['REQUEST_METHOD']
1005
+                        : null,
1006
+                ],
1007
+                $c->getSecureRandom(),
1008
+                $c->getConfig()
1009
+            );
1010
+
1011
+            return new CryptoWrapper(
1012
+                $c->getConfig(),
1013
+                $c->getCrypto(),
1014
+                $c->getSecureRandom(),
1015
+                $request
1016
+            );
1017
+        });
1018
+        $this->registerService(CsrfTokenManager::class, function (Server $c) {
1019
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1020
+
1021
+            return new CsrfTokenManager(
1022
+                $tokenGenerator,
1023
+                $c->query(SessionStorage::class)
1024
+            );
1025
+        });
1026
+        $this->registerAlias('CsrfTokenManager', CsrfTokenManager::class);
1027
+        $this->registerService(SessionStorage::class, function (Server $c) {
1028
+            return new SessionStorage($c->getSession());
1029
+        });
1030
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class);
1031
+        $this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class);
1032
+
1033
+        $this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1034
+            return new ContentSecurityPolicyNonceManager(
1035
+                $c->getCsrfTokenManager(),
1036
+                $c->getRequest()
1037
+            );
1038
+        });
1039
+
1040
+        $this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1041
+            $config = $c->getConfig();
1042
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1043
+            /** @var \OCP\Share\IProviderFactory $factory */
1044
+            $factory = new $factoryClass($this);
1045
+
1046
+            $manager = new \OC\Share20\Manager(
1047
+                $c->getLogger(),
1048
+                $c->getConfig(),
1049
+                $c->getSecureRandom(),
1050
+                $c->getHasher(),
1051
+                $c->getMountManager(),
1052
+                $c->getGroupManager(),
1053
+                $c->getL10N('lib'),
1054
+                $c->getL10NFactory(),
1055
+                $factory,
1056
+                $c->getUserManager(),
1057
+                $c->getLazyRootFolder(),
1058
+                $c->getEventDispatcher(),
1059
+                $c->getMailer(),
1060
+                $c->getURLGenerator(),
1061
+                $c->getThemingDefaults()
1062
+            );
1063
+
1064
+            return $manager;
1065
+        });
1066
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
1067
+
1068
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function(Server $c) {
1069
+            $instance = new Collaboration\Collaborators\Search($c);
1070
+
1071
+            // register default plugins
1072
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1073
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1074
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1075
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1076
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1077
+
1078
+            return $instance;
1079
+        });
1080
+        $this->registerAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
1081
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1082
+
1083
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1084
+
1085
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1086
+
1087
+        $this->registerService('SettingsManager', function (Server $c) {
1088
+            $manager = new \OC\Settings\Manager(
1089
+                $c->getLogger(),
1090
+                $c->getL10NFactory(),
1091
+                $c->getURLGenerator(),
1092
+                $c
1093
+            );
1094
+            return $manager;
1095
+        });
1096
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1097
+            return new \OC\Files\AppData\Factory(
1098
+                $c->getRootFolder(),
1099
+                $c->getSystemConfig()
1100
+            );
1101
+        });
1102
+
1103
+        $this->registerService('LockdownManager', function (Server $c) {
1104
+            return new LockdownManager(function () use ($c) {
1105
+                return $c->getSession();
1106
+            });
1107
+        });
1108
+
1109
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1110
+            return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1111
+        });
1112
+
1113
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
1114
+            return new CloudIdManager();
1115
+        });
1116
+
1117
+        $this->registerService(IConfig::class, function (Server $c) {
1118
+            return new GlobalScale\Config($c->getConfig());
1119
+        });
1120
+
1121
+        $this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1122
+            return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1123
+        });
1124
+
1125
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1126
+            return new CloudFederationFactory();
1127
+        });
1128
+
1129
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1130
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
1131
+
1132
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1133
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1134
+
1135
+        $this->registerService(Defaults::class, function (Server $c) {
1136
+            return new Defaults(
1137
+                $c->getThemingDefaults()
1138
+            );
1139
+        });
1140
+        $this->registerAlias('Defaults', \OCP\Defaults::class);
1141
+
1142
+        $this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1143
+            return $c->query(\OCP\IUserSession::class)->getSession();
1144
+        });
1145
+
1146
+        $this->registerService(IShareHelper::class, function (Server $c) {
1147
+            return new ShareHelper(
1148
+                $c->query(\OCP\Share\IManager::class)
1149
+            );
1150
+        });
1151
+
1152
+        $this->registerService(Installer::class, function(Server $c) {
1153
+            return new Installer(
1154
+                $c->getAppFetcher(),
1155
+                $c->getHTTPClientService(),
1156
+                $c->getTempManager(),
1157
+                $c->getLogger(),
1158
+                $c->getConfig()
1159
+            );
1160
+        });
1161
+
1162
+        $this->registerService(IApiFactory::class, function(Server $c) {
1163
+            return new ApiFactory($c->getHTTPClientService());
1164
+        });
1165
+
1166
+        $this->registerService(IInstanceFactory::class, function(Server $c) {
1167
+            $memcacheFactory = $c->getMemCacheFactory();
1168
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
1169
+        });
1170
+
1171
+        $this->registerService(IContactsStore::class, function(Server $c) {
1172
+            return new ContactsStore(
1173
+                $c->getContactsManager(),
1174
+                $c->getConfig(),
1175
+                $c->getUserManager(),
1176
+                $c->getGroupManager()
1177
+            );
1178
+        });
1179
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1180
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1181
+
1182
+        $this->registerService(IStorageFactory::class, function() {
1183
+            return new StorageFactory();
1184
+        });
1185
+
1186
+        $this->registerAlias(IDashboardManager::class, DashboardManager::class);
1187
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1188
+
1189
+        $this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) {
1190
+            return new \OC\Security\IdentityProof\Manager(
1191
+                $c->query(\OC\Files\AppData\Factory::class),
1192
+                $c->getCrypto(),
1193
+                $c->getConfig()
1194
+            );
1195
+        });
1196
+
1197
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1198
+
1199
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1200
+
1201
+        $this->connectDispatcher();
1202
+    }
1203
+
1204
+    /**
1205
+     * @return \OCP\Calendar\IManager
1206
+     */
1207
+    public function getCalendarManager() {
1208
+        return $this->query('CalendarManager');
1209
+    }
1210
+
1211
+    /**
1212
+     * @return \OCP\Calendar\Resource\IManager
1213
+     */
1214
+    public function getCalendarResourceBackendManager() {
1215
+        return $this->query('CalendarResourceBackendManager');
1216
+    }
1217
+
1218
+    /**
1219
+     * @return \OCP\Calendar\Room\IManager
1220
+     */
1221
+    public function getCalendarRoomBackendManager() {
1222
+        return $this->query('CalendarRoomBackendManager');
1223
+    }
1224
+
1225
+    private function connectDispatcher() {
1226
+        $dispatcher = $this->getEventDispatcher();
1227
+
1228
+        // Delete avatar on user deletion
1229
+        $dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) {
1230
+            $logger = $this->getLogger();
1231
+            $manager = $this->getAvatarManager();
1232
+            /** @var IUser $user */
1233
+            $user = $e->getSubject();
1234
+
1235
+            try {
1236
+                $avatar = $manager->getAvatar($user->getUID());
1237
+                $avatar->remove();
1238
+            } catch (NotFoundException $e) {
1239
+                // no avatar to remove
1240
+            } catch (\Exception $e) {
1241
+                // Ignore exceptions
1242
+                $logger->info('Could not cleanup avatar of ' . $user->getUID());
1243
+            }
1244
+        });
1245
+
1246
+        $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1247
+            $manager = $this->getAvatarManager();
1248
+            /** @var IUser $user */
1249
+            $user = $e->getSubject();
1250
+            $feature = $e->getArgument('feature');
1251
+            $oldValue = $e->getArgument('oldValue');
1252
+            $value = $e->getArgument('value');
1253
+
1254
+            // We only change the avatar on display name changes
1255
+            if ($feature !== 'displayName') {
1256
+                return;
1257
+            }
1258
+
1259
+            try {
1260
+                $avatar = $manager->getAvatar($user->getUID());
1261
+                $avatar->userChanged($feature, $oldValue, $value);
1262
+            } catch (NotFoundException $e) {
1263
+                // no avatar to remove
1264
+            }
1265
+        });
1266
+    }
1267
+
1268
+    /**
1269
+     * @return \OCP\Contacts\IManager
1270
+     */
1271
+    public function getContactsManager() {
1272
+        return $this->query('ContactsManager');
1273
+    }
1274
+
1275
+    /**
1276
+     * @return \OC\Encryption\Manager
1277
+     */
1278
+    public function getEncryptionManager() {
1279
+        return $this->query('EncryptionManager');
1280
+    }
1281
+
1282
+    /**
1283
+     * @return \OC\Encryption\File
1284
+     */
1285
+    public function getEncryptionFilesHelper() {
1286
+        return $this->query('EncryptionFileHelper');
1287
+    }
1288
+
1289
+    /**
1290
+     * @return \OCP\Encryption\Keys\IStorage
1291
+     */
1292
+    public function getEncryptionKeyStorage() {
1293
+        return $this->query('EncryptionKeyStorage');
1294
+    }
1295
+
1296
+    /**
1297
+     * The current request object holding all information about the request
1298
+     * currently being processed is returned from this method.
1299
+     * In case the current execution was not initiated by a web request null is returned
1300
+     *
1301
+     * @return \OCP\IRequest
1302
+     */
1303
+    public function getRequest() {
1304
+        return $this->query('Request');
1305
+    }
1306
+
1307
+    /**
1308
+     * Returns the preview manager which can create preview images for a given file
1309
+     *
1310
+     * @return \OCP\IPreview
1311
+     */
1312
+    public function getPreviewManager() {
1313
+        return $this->query('PreviewManager');
1314
+    }
1315
+
1316
+    /**
1317
+     * Returns the tag manager which can get and set tags for different object types
1318
+     *
1319
+     * @see \OCP\ITagManager::load()
1320
+     * @return \OCP\ITagManager
1321
+     */
1322
+    public function getTagManager() {
1323
+        return $this->query('TagManager');
1324
+    }
1325
+
1326
+    /**
1327
+     * Returns the system-tag manager
1328
+     *
1329
+     * @return \OCP\SystemTag\ISystemTagManager
1330
+     *
1331
+     * @since 9.0.0
1332
+     */
1333
+    public function getSystemTagManager() {
1334
+        return $this->query('SystemTagManager');
1335
+    }
1336
+
1337
+    /**
1338
+     * Returns the system-tag object mapper
1339
+     *
1340
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1341
+     *
1342
+     * @since 9.0.0
1343
+     */
1344
+    public function getSystemTagObjectMapper() {
1345
+        return $this->query('SystemTagObjectMapper');
1346
+    }
1347
+
1348
+    /**
1349
+     * Returns the avatar manager, used for avatar functionality
1350
+     *
1351
+     * @return \OCP\IAvatarManager
1352
+     */
1353
+    public function getAvatarManager() {
1354
+        return $this->query('AvatarManager');
1355
+    }
1356
+
1357
+    /**
1358
+     * Returns the root folder of ownCloud's data directory
1359
+     *
1360
+     * @return \OCP\Files\IRootFolder
1361
+     */
1362
+    public function getRootFolder() {
1363
+        return $this->query('LazyRootFolder');
1364
+    }
1365
+
1366
+    /**
1367
+     * Returns the root folder of ownCloud's data directory
1368
+     * This is the lazy variant so this gets only initialized once it
1369
+     * is actually used.
1370
+     *
1371
+     * @return \OCP\Files\IRootFolder
1372
+     */
1373
+    public function getLazyRootFolder() {
1374
+        return $this->query('LazyRootFolder');
1375
+    }
1376
+
1377
+    /**
1378
+     * Returns a view to ownCloud's files folder
1379
+     *
1380
+     * @param string $userId user ID
1381
+     * @return \OCP\Files\Folder|null
1382
+     */
1383
+    public function getUserFolder($userId = null) {
1384
+        if ($userId === null) {
1385
+            $user = $this->getUserSession()->getUser();
1386
+            if (!$user) {
1387
+                return null;
1388
+            }
1389
+            $userId = $user->getUID();
1390
+        }
1391
+        $root = $this->getRootFolder();
1392
+        return $root->getUserFolder($userId);
1393
+    }
1394
+
1395
+    /**
1396
+     * Returns an app-specific view in ownClouds data directory
1397
+     *
1398
+     * @return \OCP\Files\Folder
1399
+     * @deprecated since 9.2.0 use IAppData
1400
+     */
1401
+    public function getAppFolder() {
1402
+        $dir = '/' . \OC_App::getCurrentApp();
1403
+        $root = $this->getRootFolder();
1404
+        if (!$root->nodeExists($dir)) {
1405
+            $folder = $root->newFolder($dir);
1406
+        } else {
1407
+            $folder = $root->get($dir);
1408
+        }
1409
+        return $folder;
1410
+    }
1411
+
1412
+    /**
1413
+     * @return \OC\User\Manager
1414
+     */
1415
+    public function getUserManager() {
1416
+        return $this->query('UserManager');
1417
+    }
1418
+
1419
+    /**
1420
+     * @return \OC\Group\Manager
1421
+     */
1422
+    public function getGroupManager() {
1423
+        return $this->query('GroupManager');
1424
+    }
1425
+
1426
+    /**
1427
+     * @return \OC\User\Session
1428
+     */
1429
+    public function getUserSession() {
1430
+        return $this->query('UserSession');
1431
+    }
1432
+
1433
+    /**
1434
+     * @return \OCP\ISession
1435
+     */
1436
+    public function getSession() {
1437
+        return $this->query('UserSession')->getSession();
1438
+    }
1439
+
1440
+    /**
1441
+     * @param \OCP\ISession $session
1442
+     */
1443
+    public function setSession(\OCP\ISession $session) {
1444
+        $this->query(SessionStorage::class)->setSession($session);
1445
+        $this->query('UserSession')->setSession($session);
1446
+        $this->query(Store::class)->setSession($session);
1447
+    }
1448
+
1449
+    /**
1450
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1451
+     */
1452
+    public function getTwoFactorAuthManager() {
1453
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1454
+    }
1455
+
1456
+    /**
1457
+     * @return \OC\NavigationManager
1458
+     */
1459
+    public function getNavigationManager() {
1460
+        return $this->query('NavigationManager');
1461
+    }
1462
+
1463
+    /**
1464
+     * @return \OCP\IConfig
1465
+     */
1466
+    public function getConfig() {
1467
+        return $this->query('AllConfig');
1468
+    }
1469
+
1470
+    /**
1471
+     * @return \OC\SystemConfig
1472
+     */
1473
+    public function getSystemConfig() {
1474
+        return $this->query('SystemConfig');
1475
+    }
1476
+
1477
+    /**
1478
+     * Returns the app config manager
1479
+     *
1480
+     * @return \OCP\IAppConfig
1481
+     */
1482
+    public function getAppConfig() {
1483
+        return $this->query('AppConfig');
1484
+    }
1485
+
1486
+    /**
1487
+     * @return \OCP\L10N\IFactory
1488
+     */
1489
+    public function getL10NFactory() {
1490
+        return $this->query('L10NFactory');
1491
+    }
1492
+
1493
+    /**
1494
+     * get an L10N instance
1495
+     *
1496
+     * @param string $app appid
1497
+     * @param string $lang
1498
+     * @return IL10N
1499
+     */
1500
+    public function getL10N($app, $lang = null) {
1501
+        return $this->getL10NFactory()->get($app, $lang);
1502
+    }
1503
+
1504
+    /**
1505
+     * @return \OCP\IURLGenerator
1506
+     */
1507
+    public function getURLGenerator() {
1508
+        return $this->query('URLGenerator');
1509
+    }
1510
+
1511
+    /**
1512
+     * @return AppFetcher
1513
+     */
1514
+    public function getAppFetcher() {
1515
+        return $this->query(AppFetcher::class);
1516
+    }
1517
+
1518
+    /**
1519
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1520
+     * getMemCacheFactory() instead.
1521
+     *
1522
+     * @return \OCP\ICache
1523
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1524
+     */
1525
+    public function getCache() {
1526
+        return $this->query('UserCache');
1527
+    }
1528
+
1529
+    /**
1530
+     * Returns an \OCP\CacheFactory instance
1531
+     *
1532
+     * @return \OCP\ICacheFactory
1533
+     */
1534
+    public function getMemCacheFactory() {
1535
+        return $this->query('MemCacheFactory');
1536
+    }
1537
+
1538
+    /**
1539
+     * Returns an \OC\RedisFactory instance
1540
+     *
1541
+     * @return \OC\RedisFactory
1542
+     */
1543
+    public function getGetRedisFactory() {
1544
+        return $this->query('RedisFactory');
1545
+    }
1546
+
1547
+
1548
+    /**
1549
+     * Returns the current session
1550
+     *
1551
+     * @return \OCP\IDBConnection
1552
+     */
1553
+    public function getDatabaseConnection() {
1554
+        return $this->query('DatabaseConnection');
1555
+    }
1556
+
1557
+    /**
1558
+     * Returns the activity manager
1559
+     *
1560
+     * @return \OCP\Activity\IManager
1561
+     */
1562
+    public function getActivityManager() {
1563
+        return $this->query('ActivityManager');
1564
+    }
1565
+
1566
+    /**
1567
+     * Returns an job list for controlling background jobs
1568
+     *
1569
+     * @return \OCP\BackgroundJob\IJobList
1570
+     */
1571
+    public function getJobList() {
1572
+        return $this->query('JobList');
1573
+    }
1574
+
1575
+    /**
1576
+     * Returns a logger instance
1577
+     *
1578
+     * @return \OCP\ILogger
1579
+     */
1580
+    public function getLogger() {
1581
+        return $this->query('Logger');
1582
+    }
1583
+
1584
+    /**
1585
+     * @return ILogFactory
1586
+     * @throws \OCP\AppFramework\QueryException
1587
+     */
1588
+    public function getLogFactory() {
1589
+        return $this->query(ILogFactory::class);
1590
+    }
1591
+
1592
+    /**
1593
+     * Returns a router for generating and matching urls
1594
+     *
1595
+     * @return \OCP\Route\IRouter
1596
+     */
1597
+    public function getRouter() {
1598
+        return $this->query('Router');
1599
+    }
1600
+
1601
+    /**
1602
+     * Returns a search instance
1603
+     *
1604
+     * @return \OCP\ISearch
1605
+     */
1606
+    public function getSearch() {
1607
+        return $this->query('Search');
1608
+    }
1609
+
1610
+    /**
1611
+     * Returns a SecureRandom instance
1612
+     *
1613
+     * @return \OCP\Security\ISecureRandom
1614
+     */
1615
+    public function getSecureRandom() {
1616
+        return $this->query('SecureRandom');
1617
+    }
1618
+
1619
+    /**
1620
+     * Returns a Crypto instance
1621
+     *
1622
+     * @return \OCP\Security\ICrypto
1623
+     */
1624
+    public function getCrypto() {
1625
+        return $this->query('Crypto');
1626
+    }
1627
+
1628
+    /**
1629
+     * Returns a Hasher instance
1630
+     *
1631
+     * @return \OCP\Security\IHasher
1632
+     */
1633
+    public function getHasher() {
1634
+        return $this->query('Hasher');
1635
+    }
1636
+
1637
+    /**
1638
+     * Returns a CredentialsManager instance
1639
+     *
1640
+     * @return \OCP\Security\ICredentialsManager
1641
+     */
1642
+    public function getCredentialsManager() {
1643
+        return $this->query('CredentialsManager');
1644
+    }
1645
+
1646
+    /**
1647
+     * Get the certificate manager for the user
1648
+     *
1649
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1650
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1651
+     */
1652
+    public function getCertificateManager($userId = '') {
1653
+        if ($userId === '') {
1654
+            $userSession = $this->getUserSession();
1655
+            $user = $userSession->getUser();
1656
+            if (is_null($user)) {
1657
+                return null;
1658
+            }
1659
+            $userId = $user->getUID();
1660
+        }
1661
+        return new CertificateManager(
1662
+            $userId,
1663
+            new View(),
1664
+            $this->getConfig(),
1665
+            $this->getLogger(),
1666
+            $this->getSecureRandom()
1667
+        );
1668
+    }
1669
+
1670
+    /**
1671
+     * Returns an instance of the HTTP client service
1672
+     *
1673
+     * @return \OCP\Http\Client\IClientService
1674
+     */
1675
+    public function getHTTPClientService() {
1676
+        return $this->query('HttpClientService');
1677
+    }
1678
+
1679
+    /**
1680
+     * Create a new event source
1681
+     *
1682
+     * @return \OCP\IEventSource
1683
+     */
1684
+    public function createEventSource() {
1685
+        return new \OC_EventSource();
1686
+    }
1687
+
1688
+    /**
1689
+     * Get the active event logger
1690
+     *
1691
+     * The returned logger only logs data when debug mode is enabled
1692
+     *
1693
+     * @return \OCP\Diagnostics\IEventLogger
1694
+     */
1695
+    public function getEventLogger() {
1696
+        return $this->query('EventLogger');
1697
+    }
1698
+
1699
+    /**
1700
+     * Get the active query logger
1701
+     *
1702
+     * The returned logger only logs data when debug mode is enabled
1703
+     *
1704
+     * @return \OCP\Diagnostics\IQueryLogger
1705
+     */
1706
+    public function getQueryLogger() {
1707
+        return $this->query('QueryLogger');
1708
+    }
1709
+
1710
+    /**
1711
+     * Get the manager for temporary files and folders
1712
+     *
1713
+     * @return \OCP\ITempManager
1714
+     */
1715
+    public function getTempManager() {
1716
+        return $this->query('TempManager');
1717
+    }
1718
+
1719
+    /**
1720
+     * Get the app manager
1721
+     *
1722
+     * @return \OCP\App\IAppManager
1723
+     */
1724
+    public function getAppManager() {
1725
+        return $this->query('AppManager');
1726
+    }
1727
+
1728
+    /**
1729
+     * Creates a new mailer
1730
+     *
1731
+     * @return \OCP\Mail\IMailer
1732
+     */
1733
+    public function getMailer() {
1734
+        return $this->query('Mailer');
1735
+    }
1736
+
1737
+    /**
1738
+     * Get the webroot
1739
+     *
1740
+     * @return string
1741
+     */
1742
+    public function getWebRoot() {
1743
+        return $this->webRoot;
1744
+    }
1745
+
1746
+    /**
1747
+     * @return \OC\OCSClient
1748
+     */
1749
+    public function getOcsClient() {
1750
+        return $this->query('OcsClient');
1751
+    }
1752
+
1753
+    /**
1754
+     * @return \OCP\IDateTimeZone
1755
+     */
1756
+    public function getDateTimeZone() {
1757
+        return $this->query('DateTimeZone');
1758
+    }
1759
+
1760
+    /**
1761
+     * @return \OCP\IDateTimeFormatter
1762
+     */
1763
+    public function getDateTimeFormatter() {
1764
+        return $this->query('DateTimeFormatter');
1765
+    }
1766
+
1767
+    /**
1768
+     * @return \OCP\Files\Config\IMountProviderCollection
1769
+     */
1770
+    public function getMountProviderCollection() {
1771
+        return $this->query('MountConfigManager');
1772
+    }
1773
+
1774
+    /**
1775
+     * Get the IniWrapper
1776
+     *
1777
+     * @return IniGetWrapper
1778
+     */
1779
+    public function getIniWrapper() {
1780
+        return $this->query('IniWrapper');
1781
+    }
1782
+
1783
+    /**
1784
+     * @return \OCP\Command\IBus
1785
+     */
1786
+    public function getCommandBus() {
1787
+        return $this->query('AsyncCommandBus');
1788
+    }
1789
+
1790
+    /**
1791
+     * Get the trusted domain helper
1792
+     *
1793
+     * @return TrustedDomainHelper
1794
+     */
1795
+    public function getTrustedDomainHelper() {
1796
+        return $this->query('TrustedDomainHelper');
1797
+    }
1798
+
1799
+    /**
1800
+     * Get the locking provider
1801
+     *
1802
+     * @return \OCP\Lock\ILockingProvider
1803
+     * @since 8.1.0
1804
+     */
1805
+    public function getLockingProvider() {
1806
+        return $this->query('LockingProvider');
1807
+    }
1808
+
1809
+    /**
1810
+     * @return \OCP\Files\Mount\IMountManager
1811
+     **/
1812
+    function getMountManager() {
1813
+        return $this->query('MountManager');
1814
+    }
1815
+
1816
+    /** @return \OCP\Files\Config\IUserMountCache */
1817
+    function getUserMountCache() {
1818
+        return $this->query('UserMountCache');
1819
+    }
1820
+
1821
+    /**
1822
+     * Get the MimeTypeDetector
1823
+     *
1824
+     * @return \OCP\Files\IMimeTypeDetector
1825
+     */
1826
+    public function getMimeTypeDetector() {
1827
+        return $this->query('MimeTypeDetector');
1828
+    }
1829
+
1830
+    /**
1831
+     * Get the MimeTypeLoader
1832
+     *
1833
+     * @return \OCP\Files\IMimeTypeLoader
1834
+     */
1835
+    public function getMimeTypeLoader() {
1836
+        return $this->query('MimeTypeLoader');
1837
+    }
1838
+
1839
+    /**
1840
+     * Get the manager of all the capabilities
1841
+     *
1842
+     * @return \OC\CapabilitiesManager
1843
+     */
1844
+    public function getCapabilitiesManager() {
1845
+        return $this->query('CapabilitiesManager');
1846
+    }
1847
+
1848
+    /**
1849
+     * Get the EventDispatcher
1850
+     *
1851
+     * @return EventDispatcherInterface
1852
+     * @since 8.2.0
1853
+     */
1854
+    public function getEventDispatcher() {
1855
+        return $this->query(\OC\EventDispatcher\SymfonyAdapter::class);
1856
+    }
1857
+
1858
+    /**
1859
+     * Get the Notification Manager
1860
+     *
1861
+     * @return \OCP\Notification\IManager
1862
+     * @since 8.2.0
1863
+     */
1864
+    public function getNotificationManager() {
1865
+        return $this->query('NotificationManager');
1866
+    }
1867
+
1868
+    /**
1869
+     * @return \OCP\Comments\ICommentsManager
1870
+     */
1871
+    public function getCommentsManager() {
1872
+        return $this->query('CommentsManager');
1873
+    }
1874
+
1875
+    /**
1876
+     * @return \OCA\Theming\ThemingDefaults
1877
+     */
1878
+    public function getThemingDefaults() {
1879
+        return $this->query('ThemingDefaults');
1880
+    }
1881
+
1882
+    /**
1883
+     * @return \OC\IntegrityCheck\Checker
1884
+     */
1885
+    public function getIntegrityCodeChecker() {
1886
+        return $this->query('IntegrityCodeChecker');
1887
+    }
1888
+
1889
+    /**
1890
+     * @return \OC\Session\CryptoWrapper
1891
+     */
1892
+    public function getSessionCryptoWrapper() {
1893
+        return $this->query('CryptoWrapper');
1894
+    }
1895
+
1896
+    /**
1897
+     * @return CsrfTokenManager
1898
+     */
1899
+    public function getCsrfTokenManager() {
1900
+        return $this->query(CsrfTokenManager::class);
1901
+    }
1902
+
1903
+    /**
1904
+     * @return Throttler
1905
+     */
1906
+    public function getBruteForceThrottler() {
1907
+        return $this->query('Throttler');
1908
+    }
1909
+
1910
+    /**
1911
+     * @return IContentSecurityPolicyManager
1912
+     */
1913
+    public function getContentSecurityPolicyManager() {
1914
+        return $this->query('ContentSecurityPolicyManager');
1915
+    }
1916
+
1917
+    /**
1918
+     * @return ContentSecurityPolicyNonceManager
1919
+     */
1920
+    public function getContentSecurityPolicyNonceManager() {
1921
+        return $this->query('ContentSecurityPolicyNonceManager');
1922
+    }
1923
+
1924
+    /**
1925
+     * Not a public API as of 8.2, wait for 9.0
1926
+     *
1927
+     * @return \OCA\Files_External\Service\BackendService
1928
+     */
1929
+    public function getStoragesBackendService() {
1930
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1931
+    }
1932
+
1933
+    /**
1934
+     * Not a public API as of 8.2, wait for 9.0
1935
+     *
1936
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1937
+     */
1938
+    public function getGlobalStoragesService() {
1939
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1940
+    }
1941
+
1942
+    /**
1943
+     * Not a public API as of 8.2, wait for 9.0
1944
+     *
1945
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1946
+     */
1947
+    public function getUserGlobalStoragesService() {
1948
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1949
+    }
1950
+
1951
+    /**
1952
+     * Not a public API as of 8.2, wait for 9.0
1953
+     *
1954
+     * @return \OCA\Files_External\Service\UserStoragesService
1955
+     */
1956
+    public function getUserStoragesService() {
1957
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1958
+    }
1959
+
1960
+    /**
1961
+     * @return \OCP\Share\IManager
1962
+     */
1963
+    public function getShareManager() {
1964
+        return $this->query('ShareManager');
1965
+    }
1966
+
1967
+    /**
1968
+     * @return \OCP\Collaboration\Collaborators\ISearch
1969
+     */
1970
+    public function getCollaboratorSearch() {
1971
+        return $this->query('CollaboratorSearch');
1972
+    }
1973
+
1974
+    /**
1975
+     * @return \OCP\Collaboration\AutoComplete\IManager
1976
+     */
1977
+    public function getAutoCompleteManager(){
1978
+        return $this->query(IManager::class);
1979
+    }
1980
+
1981
+    /**
1982
+     * Returns the LDAP Provider
1983
+     *
1984
+     * @return \OCP\LDAP\ILDAPProvider
1985
+     */
1986
+    public function getLDAPProvider() {
1987
+        return $this->query('LDAPProvider');
1988
+    }
1989
+
1990
+    /**
1991
+     * @return \OCP\Settings\IManager
1992
+     */
1993
+    public function getSettingsManager() {
1994
+        return $this->query('SettingsManager');
1995
+    }
1996
+
1997
+    /**
1998
+     * @return \OCP\Files\IAppData
1999
+     */
2000
+    public function getAppDataDir($app) {
2001
+        /** @var \OC\Files\AppData\Factory $factory */
2002
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
2003
+        return $factory->get($app);
2004
+    }
2005
+
2006
+    /**
2007
+     * @return \OCP\Lockdown\ILockdownManager
2008
+     */
2009
+    public function getLockdownManager() {
2010
+        return $this->query('LockdownManager');
2011
+    }
2012
+
2013
+    /**
2014
+     * @return \OCP\Federation\ICloudIdManager
2015
+     */
2016
+    public function getCloudIdManager() {
2017
+        return $this->query(ICloudIdManager::class);
2018
+    }
2019
+
2020
+    /**
2021
+     * @return \OCP\GlobalScale\IConfig
2022
+     */
2023
+    public function getGlobalScaleConfig() {
2024
+        return $this->query(IConfig::class);
2025
+    }
2026
+
2027
+    /**
2028
+     * @return \OCP\Federation\ICloudFederationProviderManager
2029
+     */
2030
+    public function getCloudFederationProviderManager() {
2031
+        return $this->query(ICloudFederationProviderManager::class);
2032
+    }
2033
+
2034
+    /**
2035
+     * @return \OCP\Remote\Api\IApiFactory
2036
+     */
2037
+    public function getRemoteApiFactory() {
2038
+        return $this->query(IApiFactory::class);
2039
+    }
2040
+
2041
+    /**
2042
+     * @return \OCP\Federation\ICloudFederationFactory
2043
+     */
2044
+    public function getCloudFederationFactory() {
2045
+        return $this->query(ICloudFederationFactory::class);
2046
+    }
2047
+
2048
+    /**
2049
+     * @return \OCP\Remote\IInstanceFactory
2050
+     */
2051
+    public function getRemoteInstanceFactory() {
2052
+        return $this->query(IInstanceFactory::class);
2053
+    }
2054
+
2055
+    /**
2056
+     * @return IStorageFactory
2057
+     */
2058
+    public function getStorageFactory() {
2059
+        return $this->query(IStorageFactory::class);
2060
+    }
2061
+
2062
+    /**
2063
+     * Get the Preview GeneratorHelper
2064
+     *
2065
+     * @return GeneratorHelper
2066
+     * @since 17.0.0
2067
+     */
2068
+    public function getGeneratorHelper() {
2069
+        return $this->query(\OC\Preview\GeneratorHelper::class);
2070
+    }
2071 2071
 }
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 		// To find out if we are running from CLI or not
184 184
 		$this->registerParameter('isCLI', \OC::$CLI);
185 185
 
186
-		$this->registerService(\OCP\IServerContainer::class, function (IServerContainer $c) {
186
+		$this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) {
187 187
 			return $c;
188 188
 		});
189 189
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$this->registerAlias(IActionFactory::class, ActionFactory::class);
203 203
 
204 204
 
205
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
205
+		$this->registerService(\OCP\IPreview::class, function(Server $c) {
206 206
 			return new PreviewManager(
207 207
 				$c->getConfig(),
208 208
 				$c->getRootFolder(),
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 		});
215 215
 		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
216 216
 
217
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
217
+		$this->registerService(\OC\Preview\Watcher::class, function(Server $c) {
218 218
 			return new \OC\Preview\Watcher(
219 219
 				$c->getAppDataDir('preview')
220 220
 			);
221 221
 		});
222 222
 
223
-		$this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
223
+		$this->registerService(\OCP\Encryption\IManager::class, function(Server $c) {
224 224
 			$view = new View();
225 225
 			$util = new Encryption\Util(
226 226
 				$view,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		});
240 240
 		$this->registerAlias('EncryptionManager', \OCP\Encryption\IManager::class);
241 241
 
242
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
242
+		$this->registerService('EncryptionFileHelper', function(Server $c) {
243 243
 			$util = new Encryption\Util(
244 244
 				new View(),
245 245
 				$c->getUserManager(),
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			);
254 254
 		});
255 255
 
256
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
256
+		$this->registerService('EncryptionKeyStorage', function(Server $c) {
257 257
 			$view = new View();
258 258
 			$util = new Encryption\Util(
259 259
 				$view,
@@ -264,30 +264,30 @@  discard block
 block discarded – undo
264 264
 
265 265
 			return new Encryption\Keys\Storage($view, $util);
266 266
 		});
267
-		$this->registerService('TagMapper', function (Server $c) {
267
+		$this->registerService('TagMapper', function(Server $c) {
268 268
 			return new TagMapper($c->getDatabaseConnection());
269 269
 		});
270 270
 
271
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
271
+		$this->registerService(\OCP\ITagManager::class, function(Server $c) {
272 272
 			$tagMapper = $c->query('TagMapper');
273 273
 			return new TagManager($tagMapper, $c->getUserSession());
274 274
 		});
275 275
 		$this->registerAlias('TagManager', \OCP\ITagManager::class);
276 276
 
277
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
277
+		$this->registerService('SystemTagManagerFactory', function(Server $c) {
278 278
 			$config = $c->getConfig();
279 279
 			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
280 280
 			return new $factoryClass($this);
281 281
 		});
282
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
282
+		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) {
283 283
 			return $c->query('SystemTagManagerFactory')->getManager();
284 284
 		});
285 285
 		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
286 286
 
287
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
287
+		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) {
288 288
 			return $c->query('SystemTagManagerFactory')->getObjectMapper();
289 289
 		});
290
-		$this->registerService('RootFolder', function (Server $c) {
290
+		$this->registerService('RootFolder', function(Server $c) {
291 291
 			$manager = \OC\Files\Filesystem::getMountManager(null);
292 292
 			$view = new View();
293 293
 			$root = new Root(
@@ -308,37 +308,37 @@  discard block
 block discarded – undo
308 308
 		});
309 309
 		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
310 310
 
311
-		$this->registerService(\OCP\Files\IRootFolder::class, function (Server $c) {
312
-			return new LazyRoot(function () use ($c) {
311
+		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
312
+			return new LazyRoot(function() use ($c) {
313 313
 				return $c->query('RootFolder');
314 314
 			});
315 315
 		});
316 316
 		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
317 317
 
318
-		$this->registerService(\OC\User\Manager::class, function (Server $c) {
318
+		$this->registerService(\OC\User\Manager::class, function(Server $c) {
319 319
 			return new \OC\User\Manager($c->getConfig(), $c->getEventDispatcher());
320 320
 		});
321 321
 		$this->registerAlias('UserManager', \OC\User\Manager::class);
322 322
 		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
323 323
 
324
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
324
+		$this->registerService(\OCP\IGroupManager::class, function(Server $c) {
325 325
 			$groupManager = new \OC\Group\Manager($this->getUserManager(), $c->getEventDispatcher(), $this->getLogger());
326
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
326
+			$groupManager->listen('\OC\Group', 'preCreate', function($gid) {
327 327
 				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
328 328
 			});
329
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
329
+			$groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) {
330 330
 				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
331 331
 			});
332
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
332
+			$groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) {
333 333
 				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
334 334
 			});
335
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
335
+			$groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) {
336 336
 				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
337 337
 			});
338
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
338
+			$groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
339 339
 				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
340 340
 			});
341
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
341
+			$groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) {
342 342
 				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
343 343
 				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
344 344
 				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		});
348 348
 		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
349 349
 
350
-		$this->registerService(Store::class, function (Server $c) {
350
+		$this->registerService(Store::class, function(Server $c) {
351 351
 			$session = $c->getSession();
352 352
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
353 353
 				$tokenProvider = $c->query(IProvider::class);
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 			return new Store($session, $logger, $tokenProvider);
359 359
 		});
360 360
 		$this->registerAlias(IStore::class, Store::class);
361
-		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function (Server $c) {
361
+		$this->registerService(Authentication\Token\DefaultTokenMapper::class, function(Server $c) {
362 362
 			$dbConnection = $c->getDatabaseConnection();
363 363
 			return new Authentication\Token\DefaultTokenMapper($dbConnection);
364 364
 		});
365 365
 		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
366 366
 
367
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
367
+		$this->registerService(\OC\User\Session::class, function(Server $c) {
368 368
 			$manager = $c->getUserManager();
369 369
 			$session = new \OC\Session\Memory('');
370 370
 			$timeFactory = new TimeFactory();
@@ -389,45 +389,45 @@  discard block
 block discarded – undo
389 389
 				$c->getLogger(),
390 390
 				$c->query(IEventDispatcher::class)
391 391
 			);
392
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
392
+			$userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) {
393 393
 				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
394 394
 			});
395
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
395
+			$userSession->listen('\OC\User', 'postCreateUser', function($user, $password) {
396 396
 				/** @var $user \OC\User\User */
397 397
 				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
398 398
 			});
399
-			$userSession->listen('\OC\User', 'preDelete', function ($user) use ($dispatcher) {
399
+			$userSession->listen('\OC\User', 'preDelete', function($user) use ($dispatcher) {
400 400
 				/** @var $user \OC\User\User */
401 401
 				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
402 402
 				$dispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
403 403
 			});
404
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
404
+			$userSession->listen('\OC\User', 'postDelete', function($user) {
405 405
 				/** @var $user \OC\User\User */
406 406
 				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
407 407
 			});
408
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
408
+			$userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) {
409 409
 				/** @var $user \OC\User\User */
410 410
 				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
411 411
 			});
412
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
412
+			$userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) {
413 413
 				/** @var $user \OC\User\User */
414 414
 				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
415 415
 			});
416
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
416
+			$userSession->listen('\OC\User', 'preLogin', function($uid, $password) {
417 417
 				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
418 418
 			});
419
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password, $isTokenLogin) {
419
+			$userSession->listen('\OC\User', 'postLogin', function($user, $password, $isTokenLogin) {
420 420
 				/** @var $user \OC\User\User */
421 421
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'isTokenLogin' => $isTokenLogin));
422 422
 			});
423
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
423
+			$userSession->listen('\OC\User', 'postRememberedLogin', function($user, $password) {
424 424
 				/** @var $user \OC\User\User */
425 425
 				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
426 426
 			});
427
-			$userSession->listen('\OC\User', 'logout', function () {
427
+			$userSession->listen('\OC\User', 'logout', function() {
428 428
 				\OC_Hook::emit('OC_User', 'logout', array());
429 429
 			});
430
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
430
+			$userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) {
431 431
 				/** @var $user \OC\User\User */
432 432
 				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
433 433
 			});
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		$this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class);
442 442
 		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
443 443
 
444
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
444
+		$this->registerService(\OC\AllConfig::class, function(Server $c) {
445 445
 			return new \OC\AllConfig(
446 446
 				$c->getSystemConfig()
447 447
 			);
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
 		$this->registerAlias('AllConfig', \OC\AllConfig::class);
450 450
 		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
451 451
 
452
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
452
+		$this->registerService(\OC\SystemConfig::class, function($c) use ($config) {
453 453
 			return new \OC\SystemConfig($config);
454 454
 		});
455 455
 		$this->registerAlias('SystemConfig', \OC\SystemConfig::class);
456 456
 
457
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
457
+		$this->registerService(\OC\AppConfig::class, function(Server $c) {
458 458
 			return new \OC\AppConfig($c->getDatabaseConnection());
459 459
 		});
460 460
 		$this->registerAlias('AppConfig', \OC\AppConfig::class);
461 461
 		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
462 462
 
463
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
463
+		$this->registerService(\OCP\L10N\IFactory::class, function(Server $c) {
464 464
 			return new \OC\L10N\Factory(
465 465
 				$c->getConfig(),
466 466
 				$c->getRequest(),
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		});
471 471
 		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
472 472
 
473
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
473
+		$this->registerService(\OCP\IURLGenerator::class, function(Server $c) {
474 474
 			$config = $c->getConfig();
475 475
 			$cacheFactory = $c->getMemCacheFactory();
476 476
 			$request = $c->getRequest();
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 		$this->registerAlias('AppFetcher', AppFetcher::class);
486 486
 		$this->registerAlias('CategoryFetcher', CategoryFetcher::class);
487 487
 
488
-		$this->registerService(\OCP\ICache::class, function ($c) {
488
+		$this->registerService(\OCP\ICache::class, function($c) {
489 489
 			return new Cache\File();
490 490
 		});
491 491
 		$this->registerAlias('UserCache', \OCP\ICache::class);
492 492
 
493
-		$this->registerService(Factory::class, function (Server $c) {
493
+		$this->registerService(Factory::class, function(Server $c) {
494 494
 
495 495
 			$arrayCacheFactory = new \OC\Memcache\Factory('', $c->getLogger(),
496 496
 				ArrayCache::class,
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				$version = implode(',', $v);
506 506
 				$instanceId = \OC_Util::getInstanceId();
507 507
 				$path = \OC::$SERVERROOT;
508
-				$prefix = md5($instanceId . '-' . $version . '-' . $path);
508
+				$prefix = md5($instanceId.'-'.$version.'-'.$path);
509 509
 				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
510 510
 					$config->getSystemValue('memcache.local', null),
511 511
 					$config->getSystemValue('memcache.distributed', null),
@@ -518,12 +518,12 @@  discard block
 block discarded – undo
518 518
 		$this->registerAlias('MemCacheFactory', Factory::class);
519 519
 		$this->registerAlias(ICacheFactory::class, Factory::class);
520 520
 
521
-		$this->registerService('RedisFactory', function (Server $c) {
521
+		$this->registerService('RedisFactory', function(Server $c) {
522 522
 			$systemConfig = $c->getSystemConfig();
523 523
 			return new RedisFactory($systemConfig);
524 524
 		});
525 525
 
526
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
526
+		$this->registerService(\OCP\Activity\IManager::class, function(Server $c) {
527 527
 			return new \OC\Activity\Manager(
528 528
 				$c->getRequest(),
529 529
 				$c->getUserSession(),
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 		});
534 534
 		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
535 535
 
536
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
536
+		$this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) {
537 537
 			return new \OC\Activity\EventMerger(
538 538
 				$c->getL10N('lib')
539 539
 			);
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
556 556
 		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
557 557
 
558
-		$this->registerService(\OC\Log::class, function (Server $c) {
558
+		$this->registerService(\OC\Log::class, function(Server $c) {
559 559
 			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
560 560
 			$factory = new LogFactory($c, $this->getSystemConfig());
561 561
 			$logger = $factory->get($logType);
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
 		$this->registerAlias(\OCP\ILogger::class, \OC\Log::class);
567 567
 		$this->registerAlias('Logger', \OC\Log::class);
568 568
 
569
-		$this->registerService(ILogFactory::class, function (Server $c) {
569
+		$this->registerService(ILogFactory::class, function(Server $c) {
570 570
 			return new LogFactory($c, $this->getSystemConfig());
571 571
 		});
572 572
 
573
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
573
+		$this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) {
574 574
 			$config = $c->getConfig();
575 575
 			return new \OC\BackgroundJob\JobList(
576 576
 				$c->getDatabaseConnection(),
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 		});
581 581
 		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
582 582
 
583
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
583
+		$this->registerService(\OCP\Route\IRouter::class, function(Server $c) {
584 584
 			$cacheFactory = $c->getMemCacheFactory();
585 585
 			$logger = $c->getLogger();
586 586
 			if ($cacheFactory->isLocalCacheAvailable()) {
@@ -592,39 +592,39 @@  discard block
 block discarded – undo
592 592
 		});
593 593
 		$this->registerAlias('Router', \OCP\Route\IRouter::class);
594 594
 
595
-		$this->registerService(\OCP\ISearch::class, function ($c) {
595
+		$this->registerService(\OCP\ISearch::class, function($c) {
596 596
 			return new Search();
597 597
 		});
598 598
 		$this->registerAlias('Search', \OCP\ISearch::class);
599 599
 
600
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
600
+		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) {
601 601
 			return new \OC\Security\RateLimiting\Backend\MemoryCache(
602 602
 				$this->getMemCacheFactory(),
603 603
 				new \OC\AppFramework\Utility\TimeFactory()
604 604
 			);
605 605
 		});
606 606
 
607
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
607
+		$this->registerService(\OCP\Security\ISecureRandom::class, function($c) {
608 608
 			return new SecureRandom();
609 609
 		});
610 610
 		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
611 611
 
612
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
612
+		$this->registerService(\OCP\Security\ICrypto::class, function(Server $c) {
613 613
 			return new Crypto($c->getConfig(), $c->getSecureRandom());
614 614
 		});
615 615
 		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
616 616
 
617
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
617
+		$this->registerService(\OCP\Security\IHasher::class, function(Server $c) {
618 618
 			return new Hasher($c->getConfig());
619 619
 		});
620 620
 		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
621 621
 
622
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
622
+		$this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) {
623 623
 			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
624 624
 		});
625 625
 		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
626 626
 
627
-		$this->registerService(IDBConnection::class, function (Server $c) {
627
+		$this->registerService(IDBConnection::class, function(Server $c) {
628 628
 			$systemConfig = $c->getSystemConfig();
629 629
 			$factory = new \OC\DB\ConnectionFactory($systemConfig);
630 630
 			$type = $systemConfig->getValue('dbtype', 'sqlite');
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 		$this->registerAlias('DatabaseConnection', IDBConnection::class);
640 640
 
641 641
 
642
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
642
+		$this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) {
643 643
 			$user = \OC_User::getUser();
644 644
 			$uid = $user ? $user : null;
645 645
 			return new ClientService(
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			);
655 655
 		});
656 656
 		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
657
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
657
+		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) {
658 658
 			$eventLogger = new EventLogger();
659 659
 			if ($c->getSystemConfig()->getValue('debug', false)) {
660 660
 				// In debug mode, module is being activated by default
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 		});
665 665
 		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
666 666
 
667
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
667
+		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) {
668 668
 			$queryLogger = new QueryLogger();
669 669
 			if ($c->getSystemConfig()->getValue('debug', false)) {
670 670
 				// In debug mode, module is being activated by default
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		});
675 675
 		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
676 676
 
677
-		$this->registerService(TempManager::class, function (Server $c) {
677
+		$this->registerService(TempManager::class, function(Server $c) {
678 678
 			return new TempManager(
679 679
 				$c->getLogger(),
680 680
 				$c->getConfig()
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 		$this->registerAlias('TempManager', TempManager::class);
684 684
 		$this->registerAlias(ITempManager::class, TempManager::class);
685 685
 
686
-		$this->registerService(AppManager::class, function (Server $c) {
686
+		$this->registerService(AppManager::class, function(Server $c) {
687 687
 			return new \OC\App\AppManager(
688 688
 				$c->getUserSession(),
689 689
 				$c->query(\OC\AppConfig::class),
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		$this->registerAlias('AppManager', AppManager::class);
697 697
 		$this->registerAlias(IAppManager::class, AppManager::class);
698 698
 
699
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
699
+		$this->registerService(\OCP\IDateTimeZone::class, function(Server $c) {
700 700
 			return new DateTimeZone(
701 701
 				$c->getConfig(),
702 702
 				$c->getSession()
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		});
705 705
 		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
706 706
 
707
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
707
+		$this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) {
708 708
 			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
709 709
 
710 710
 			return new DateTimeFormatter(
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		});
715 715
 		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
716 716
 
717
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
717
+		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) {
718 718
 			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
719 719
 			$listener = new UserMountCacheListener($mountCache);
720 720
 			$listener->listen($c->getUserManager());
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		});
723 723
 		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
724 724
 
725
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
725
+		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) {
726 726
 			$loader = \OC\Files\Filesystem::getLoader();
727 727
 			$mountCache = $c->query('UserMountCache');
728 728
 			$manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
@@ -738,10 +738,10 @@  discard block
 block discarded – undo
738 738
 		});
739 739
 		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
740 740
 
741
-		$this->registerService('IniWrapper', function ($c) {
741
+		$this->registerService('IniWrapper', function($c) {
742 742
 			return new IniGetWrapper();
743 743
 		});
744
-		$this->registerService('AsyncCommandBus', function (Server $c) {
744
+		$this->registerService('AsyncCommandBus', function(Server $c) {
745 745
 			$busClass = $c->getConfig()->getSystemValue('commandbus');
746 746
 			if ($busClass) {
747 747
 				list($app, $class) = explode('::', $busClass, 2);
@@ -756,10 +756,10 @@  discard block
 block discarded – undo
756 756
 				return new CronBus($jobList);
757 757
 			}
758 758
 		});
759
-		$this->registerService('TrustedDomainHelper', function ($c) {
759
+		$this->registerService('TrustedDomainHelper', function($c) {
760 760
 			return new TrustedDomainHelper($this->getConfig());
761 761
 		});
762
-		$this->registerService(Throttler::class, function (Server $c) {
762
+		$this->registerService(Throttler::class, function(Server $c) {
763 763
 			return new Throttler(
764 764
 				$c->getDatabaseConnection(),
765 765
 				new TimeFactory(),
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 			);
769 769
 		});
770 770
 		$this->registerAlias('Throttler', Throttler::class);
771
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
771
+		$this->registerService('IntegrityCodeChecker', function(Server $c) {
772 772
 			// IConfig and IAppManager requires a working database. This code
773 773
 			// might however be called when ownCloud is not yet setup.
774 774
 			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 				$c->getMimeTypeDetector()
791 791
 			);
792 792
 		});
793
-		$this->registerService(\OCP\IRequest::class, function ($c) {
793
+		$this->registerService(\OCP\IRequest::class, function($c) {
794 794
 			if (isset($this['urlParams'])) {
795 795
 				$urlParams = $this['urlParams'];
796 796
 			} else {
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 		});
827 827
 		$this->registerAlias('Request', \OCP\IRequest::class);
828 828
 
829
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
829
+		$this->registerService(\OCP\Mail\IMailer::class, function(Server $c) {
830 830
 			return new Mailer(
831 831
 				$c->getConfig(),
832 832
 				$c->getLogger(),
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 		});
838 838
 		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
839 839
 
840
-		$this->registerService('LDAPProvider', function (Server $c) {
840
+		$this->registerService('LDAPProvider', function(Server $c) {
841 841
 			$config = $c->getConfig();
842 842
 			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
843 843
 			if (is_null($factoryClass)) {
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 			$factory = new $factoryClass($this);
848 848
 			return $factory->getLDAPProvider();
849 849
 		});
850
-		$this->registerService(ILockingProvider::class, function (Server $c) {
850
+		$this->registerService(ILockingProvider::class, function(Server $c) {
851 851
 			$ini = $c->getIniWrapper();
852 852
 			$config = $c->getConfig();
853 853
 			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
@@ -870,30 +870,30 @@  discard block
 block discarded – undo
870 870
 		});
871 871
 		$this->registerAlias('LockingProvider', ILockingProvider::class);
872 872
 
873
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
873
+		$this->registerService(\OCP\Files\Mount\IMountManager::class, function() {
874 874
 			return new \OC\Files\Mount\Manager();
875 875
 		});
876 876
 		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
877 877
 
878
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
878
+		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) {
879 879
 			return new \OC\Files\Type\Detection(
880 880
 				$c->getURLGenerator(),
881 881
 				\OC::$configDir,
882
-				\OC::$SERVERROOT . '/resources/config/'
882
+				\OC::$SERVERROOT.'/resources/config/'
883 883
 			);
884 884
 		});
885 885
 		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
886 886
 
887
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
887
+		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) {
888 888
 			return new \OC\Files\Type\Loader(
889 889
 				$c->getDatabaseConnection()
890 890
 			);
891 891
 		});
892 892
 		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
893
-		$this->registerService(BundleFetcher::class, function () {
893
+		$this->registerService(BundleFetcher::class, function() {
894 894
 			return new BundleFetcher($this->getL10N('lib'));
895 895
 		});
896
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
896
+		$this->registerService(\OCP\Notification\IManager::class, function(Server $c) {
897 897
 			return new Manager(
898 898
 				$c->query(IValidator::class),
899 899
 				$c->getLogger()
@@ -901,19 +901,19 @@  discard block
 block discarded – undo
901 901
 		});
902 902
 		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
903 903
 
904
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
904
+		$this->registerService(\OC\CapabilitiesManager::class, function(Server $c) {
905 905
 			$manager = new \OC\CapabilitiesManager($c->getLogger());
906
-			$manager->registerCapability(function () use ($c) {
906
+			$manager->registerCapability(function() use ($c) {
907 907
 				return new \OC\OCS\CoreCapabilities($c->getConfig());
908 908
 			});
909
-			$manager->registerCapability(function () use ($c) {
909
+			$manager->registerCapability(function() use ($c) {
910 910
 				return $c->query(\OC\Security\Bruteforce\Capabilities::class);
911 911
 			});
912 912
 			return $manager;
913 913
 		});
914 914
 		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
915 915
 
916
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function (Server $c) {
916
+		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
917 917
 			$config = $c->getConfig();
918 918
 			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
919 919
 			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 			$manager->registerDisplayNameResolver('user', function($id) use ($c) {
924 924
 				$manager = $c->getUserManager();
925 925
 				$user = $manager->get($id);
926
-				if(is_null($user)) {
926
+				if (is_null($user)) {
927 927
 					$l = $c->getL10N('core');
928 928
 					$displayName = $l->t('Unknown user');
929 929
 				} else {
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 		});
937 937
 		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
938 938
 
939
-		$this->registerService('ThemingDefaults', function (Server $c) {
939
+		$this->registerService('ThemingDefaults', function(Server $c) {
940 940
 			/*
941 941
 			 * Dark magic for autoloader.
942 942
 			 * If we do a class_exists it will try to load the class which will
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			}
965 965
 			return new \OC_Defaults();
966 966
 		});
967
-		$this->registerService(SCSSCacher::class, function (Server $c) {
967
+		$this->registerService(SCSSCacher::class, function(Server $c) {
968 968
 			return new SCSSCacher(
969 969
 				$c->getLogger(),
970 970
 				$c->query(\OC\Files\AppData\Factory::class),
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 				new TimeFactory()
978 978
 			);
979 979
 		});
980
-		$this->registerService(JSCombiner::class, function (Server $c) {
980
+		$this->registerService(JSCombiner::class, function(Server $c) {
981 981
 			return new JSCombiner(
982 982
 				$c->getAppDataDir('js'),
983 983
 				$c->getURLGenerator(),
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 		$this->registerAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
991 991
 		$this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
992 992
 
993
-		$this->registerService('CryptoWrapper', function (Server $c) {
993
+		$this->registerService('CryptoWrapper', function(Server $c) {
994 994
 			// FIXME: Instantiiated here due to cyclic dependency
995 995
 			$request = new Request(
996 996
 				[
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 				$request
1016 1016
 			);
1017 1017
 		});
1018
-		$this->registerService(CsrfTokenManager::class, function (Server $c) {
1018
+		$this->registerService(CsrfTokenManager::class, function(Server $c) {
1019 1019
 			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
1020 1020
 
1021 1021
 			return new CsrfTokenManager(
@@ -1024,20 +1024,20 @@  discard block
 block discarded – undo
1024 1024
 			);
1025 1025
 		});
1026 1026
 		$this->registerAlias('CsrfTokenManager', CsrfTokenManager::class);
1027
-		$this->registerService(SessionStorage::class, function (Server $c) {
1027
+		$this->registerService(SessionStorage::class, function(Server $c) {
1028 1028
 			return new SessionStorage($c->getSession());
1029 1029
 		});
1030 1030
 		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, \OC\Security\CSP\ContentSecurityPolicyManager::class);
1031 1031
 		$this->registerAlias('ContentSecurityPolicyManager', \OC\Security\CSP\ContentSecurityPolicyManager::class);
1032 1032
 
1033
-		$this->registerService('ContentSecurityPolicyNonceManager', function (Server $c) {
1033
+		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
1034 1034
 			return new ContentSecurityPolicyNonceManager(
1035 1035
 				$c->getCsrfTokenManager(),
1036 1036
 				$c->getRequest()
1037 1037
 			);
1038 1038
 		});
1039 1039
 
1040
-		$this->registerService(\OCP\Share\IManager::class, function (Server $c) {
1040
+		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
1041 1041
 			$config = $c->getConfig();
1042 1042
 			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1043 1043
 			/** @var \OCP\Share\IProviderFactory $factory */
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 
1085 1085
 		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1086 1086
 
1087
-		$this->registerService('SettingsManager', function (Server $c) {
1087
+		$this->registerService('SettingsManager', function(Server $c) {
1088 1088
 			$manager = new \OC\Settings\Manager(
1089 1089
 				$c->getLogger(),
1090 1090
 				$c->getL10NFactory(),
@@ -1093,36 +1093,36 @@  discard block
 block discarded – undo
1093 1093
 			);
1094 1094
 			return $manager;
1095 1095
 		});
1096
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
1096
+		$this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) {
1097 1097
 			return new \OC\Files\AppData\Factory(
1098 1098
 				$c->getRootFolder(),
1099 1099
 				$c->getSystemConfig()
1100 1100
 			);
1101 1101
 		});
1102 1102
 
1103
-		$this->registerService('LockdownManager', function (Server $c) {
1104
-			return new LockdownManager(function () use ($c) {
1103
+		$this->registerService('LockdownManager', function(Server $c) {
1104
+			return new LockdownManager(function() use ($c) {
1105 1105
 				return $c->getSession();
1106 1106
 			});
1107 1107
 		});
1108 1108
 
1109
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) {
1109
+		$this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) {
1110 1110
 			return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService());
1111 1111
 		});
1112 1112
 
1113
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
1113
+		$this->registerService(ICloudIdManager::class, function(Server $c) {
1114 1114
 			return new CloudIdManager();
1115 1115
 		});
1116 1116
 
1117
-		$this->registerService(IConfig::class, function (Server $c) {
1117
+		$this->registerService(IConfig::class, function(Server $c) {
1118 1118
 			return new GlobalScale\Config($c->getConfig());
1119 1119
 		});
1120 1120
 
1121
-		$this->registerService(ICloudFederationProviderManager::class, function (Server $c) {
1121
+		$this->registerService(ICloudFederationProviderManager::class, function(Server $c) {
1122 1122
 			return new CloudFederationProviderManager($c->getAppManager(), $c->getHTTPClientService(), $c->getCloudIdManager(), $c->getLogger());
1123 1123
 		});
1124 1124
 
1125
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1125
+		$this->registerService(ICloudFederationFactory::class, function(Server $c) {
1126 1126
 			return new CloudFederationFactory();
1127 1127
 		});
1128 1128
 
@@ -1132,18 +1132,18 @@  discard block
 block discarded – undo
1132 1132
 		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1133 1133
 		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
1134 1134
 
1135
-		$this->registerService(Defaults::class, function (Server $c) {
1135
+		$this->registerService(Defaults::class, function(Server $c) {
1136 1136
 			return new Defaults(
1137 1137
 				$c->getThemingDefaults()
1138 1138
 			);
1139 1139
 		});
1140 1140
 		$this->registerAlias('Defaults', \OCP\Defaults::class);
1141 1141
 
1142
-		$this->registerService(\OCP\ISession::class, function (SimpleContainer $c) {
1142
+		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
1143 1143
 			return $c->query(\OCP\IUserSession::class)->getSession();
1144 1144
 		});
1145 1145
 
1146
-		$this->registerService(IShareHelper::class, function (Server $c) {
1146
+		$this->registerService(IShareHelper::class, function(Server $c) {
1147 1147
 			return new ShareHelper(
1148 1148
 				$c->query(\OCP\Share\IManager::class)
1149 1149
 			);
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		$this->registerAlias(IDashboardManager::class, DashboardManager::class);
1187 1187
 		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1188 1188
 
1189
-		$this->registerService(\OC\Security\IdentityProof\Manager::class, function (Server $c) {
1189
+		$this->registerService(\OC\Security\IdentityProof\Manager::class, function(Server $c) {
1190 1190
 			return new \OC\Security\IdentityProof\Manager(
1191 1191
 				$c->query(\OC\Files\AppData\Factory::class),
1192 1192
 				$c->getCrypto(),
@@ -1239,11 +1239,11 @@  discard block
 block discarded – undo
1239 1239
 				// no avatar to remove
1240 1240
 			} catch (\Exception $e) {
1241 1241
 				// Ignore exceptions
1242
-				$logger->info('Could not cleanup avatar of ' . $user->getUID());
1242
+				$logger->info('Could not cleanup avatar of '.$user->getUID());
1243 1243
 			}
1244 1244
 		});
1245 1245
 
1246
-		$dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
1246
+		$dispatcher->addListener('OCP\IUser::changeUser', function(GenericEvent $e) {
1247 1247
 			$manager = $this->getAvatarManager();
1248 1248
 			/** @var IUser $user */
1249 1249
 			$user = $e->getSubject();
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 	 * @deprecated since 9.2.0 use IAppData
1400 1400
 	 */
1401 1401
 	public function getAppFolder() {
1402
-		$dir = '/' . \OC_App::getCurrentApp();
1402
+		$dir = '/'.\OC_App::getCurrentApp();
1403 1403
 		$root = $this->getRootFolder();
1404 1404
 		if (!$root->nodeExists($dir)) {
1405 1405
 			$folder = $root->newFolder($dir);
@@ -1974,7 +1974,7 @@  discard block
 block discarded – undo
1974 1974
 	/**
1975 1975
 	 * @return \OCP\Collaboration\AutoComplete\IManager
1976 1976
 	 */
1977
-	public function getAutoCompleteManager(){
1977
+	public function getAutoCompleteManager() {
1978 1978
 		return $this->query(IManager::class);
1979 1979
 	}
1980 1980
 
Please login to merge, or discard this patch.