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