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