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