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