Completed
Push — master ( 6a013e...8210e1 )
by
unknown
25:29 queued 14s
created
lib/private/Server.php 1 patch
Indentation   +1407 added lines, -1407 removed lines patch added patch discarded remove patch
@@ -249,1448 +249,1448 @@
 block discarded – undo
249 249
  * TODO: hookup all manager classes
250 250
  */
251 251
 class Server extends ServerContainer implements IServerContainer {
252
-	/** @var string */
253
-	private $webRoot;
254
-
255
-	/**
256
-	 * @param string $webRoot
257
-	 * @param \OC\Config $config
258
-	 */
259
-	public function __construct($webRoot, \OC\Config $config) {
260
-		parent::__construct();
261
-		$this->webRoot = $webRoot;
262
-
263
-		// To find out if we are running from CLI or not
264
-		$this->registerParameter('isCLI', \OC::$CLI);
265
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
266
-
267
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
268
-			return $c;
269
-		});
270
-		$this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
271
-
272
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
273
-
274
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
275
-
276
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
277
-
278
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
279
-
280
-		$this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
281
-
282
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
283
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
284
-		$this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
285
-
286
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
287
-
288
-		$this->registerService(View::class, function (Server $c) {
289
-			return new View();
290
-		}, false);
291
-
292
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
293
-			return new PreviewManager(
294
-				$c->get(\OCP\IConfig::class),
295
-				$c->get(IRootFolder::class),
296
-				new \OC\Preview\Storage\Root(
297
-					$c->get(IRootFolder::class),
298
-					$c->get(SystemConfig::class)
299
-				),
300
-				$c->get(IEventDispatcher::class),
301
-				$c->get(GeneratorHelper::class),
302
-				$c->get(ISession::class)->get('user_id'),
303
-				$c->get(Coordinator::class),
304
-				$c->get(IServerContainer::class),
305
-				$c->get(IBinaryFinder::class),
306
-				$c->get(IMagickSupport::class)
307
-			);
308
-		});
309
-		$this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
310
-
311
-		$this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
312
-			return new \OC\Preview\Watcher(
313
-				new \OC\Preview\Storage\Root(
314
-					$c->get(IRootFolder::class),
315
-					$c->get(SystemConfig::class)
316
-				)
317
-			);
318
-		});
319
-
320
-		$this->registerService(IProfiler::class, function (Server $c) {
321
-			return new Profiler($c->get(SystemConfig::class));
322
-		});
323
-
324
-		$this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
325
-			$view = new View();
326
-			$util = new Encryption\Util(
327
-				$view,
328
-				$c->get(IUserManager::class),
329
-				$c->get(IGroupManager::class),
330
-				$c->get(\OCP\IConfig::class)
331
-			);
332
-			return new Encryption\Manager(
333
-				$c->get(\OCP\IConfig::class),
334
-				$c->get(LoggerInterface::class),
335
-				$c->getL10N('core'),
336
-				new View(),
337
-				$util,
338
-				new ArrayCache()
339
-			);
340
-		});
341
-		$this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
342
-
343
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
344
-			$util = new Encryption\Util(
345
-				new View(),
346
-				$c->get(IUserManager::class),
347
-				$c->get(IGroupManager::class),
348
-				$c->get(\OCP\IConfig::class)
349
-			);
350
-			return new Encryption\File(
351
-				$util,
352
-				$c->get(IRootFolder::class),
353
-				$c->get(\OCP\Share\IManager::class)
354
-			);
355
-		});
356
-
357
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
358
-			$view = new View();
359
-			$util = new Encryption\Util(
360
-				$view,
361
-				$c->get(IUserManager::class),
362
-				$c->get(IGroupManager::class),
363
-				$c->get(\OCP\IConfig::class)
364
-			);
365
-
366
-			return new Encryption\Keys\Storage(
367
-				$view,
368
-				$util,
369
-				$c->get(ICrypto::class),
370
-				$c->get(\OCP\IConfig::class)
371
-			);
372
-		});
373
-
374
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
375
-
376
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
377
-			/** @var \OCP\IConfig $config */
378
-			$config = $c->get(\OCP\IConfig::class);
379
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
380
-			return new $factoryClass($this);
381
-		});
382
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
383
-			return $c->get('SystemTagManagerFactory')->getManager();
384
-		});
385
-		/** @deprecated 19.0.0 */
386
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
387
-
388
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
389
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
390
-		});
391
-		$this->registerAlias(IFileAccess::class, FileAccess::class);
392
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
393
-			$manager = \OC\Files\Filesystem::getMountManager();
394
-			$view = new View();
395
-			/** @var IUserSession $userSession */
396
-			$userSession = $c->get(IUserSession::class);
397
-			$root = new Root(
398
-				$manager,
399
-				$view,
400
-				$userSession->getUser(),
401
-				$c->get(IUserMountCache::class),
402
-				$this->get(LoggerInterface::class),
403
-				$this->get(IUserManager::class),
404
-				$this->get(IEventDispatcher::class),
405
-				$this->get(ICacheFactory::class),
406
-			);
407
-
408
-			$previewConnector = new \OC\Preview\WatcherConnector(
409
-				$root,
410
-				$c->get(SystemConfig::class),
411
-				$this->get(IEventDispatcher::class)
412
-			);
413
-			$previewConnector->connectWatcher();
414
-
415
-			return $root;
416
-		});
417
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
418
-			return new HookConnector(
419
-				$c->get(IRootFolder::class),
420
-				new View(),
421
-				$c->get(IEventDispatcher::class),
422
-				$c->get(LoggerInterface::class)
423
-			);
424
-		});
425
-
426
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
427
-			return new LazyRoot(function () use ($c) {
428
-				return $c->get('RootFolder');
429
-			});
430
-		});
431
-
432
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
433
-
434
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
435
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
436
-		});
437
-
438
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
439
-			$groupManager = new \OC\Group\Manager(
440
-				$this->get(IUserManager::class),
441
-				$this->get(IEventDispatcher::class),
442
-				$this->get(LoggerInterface::class),
443
-				$this->get(ICacheFactory::class),
444
-				$this->get(IRemoteAddress::class),
445
-			);
446
-			return $groupManager;
447
-		});
448
-
449
-		$this->registerService(Store::class, function (ContainerInterface $c) {
450
-			$session = $c->get(ISession::class);
451
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
452
-				$tokenProvider = $c->get(IProvider::class);
453
-			} else {
454
-				$tokenProvider = null;
455
-			}
456
-			$logger = $c->get(LoggerInterface::class);
457
-			$crypto = $c->get(ICrypto::class);
458
-			return new Store($session, $logger, $crypto, $tokenProvider);
459
-		});
460
-		$this->registerAlias(IStore::class, Store::class);
461
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
462
-		$this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
463
-
464
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
465
-			$manager = $c->get(IUserManager::class);
466
-			$session = new \OC\Session\Memory();
467
-			$timeFactory = new TimeFactory();
468
-			// Token providers might require a working database. This code
469
-			// might however be called when Nextcloud is not yet setup.
470
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
471
-				$provider = $c->get(IProvider::class);
472
-			} else {
473
-				$provider = null;
474
-			}
475
-
476
-			$userSession = new \OC\User\Session(
477
-				$manager,
478
-				$session,
479
-				$timeFactory,
480
-				$provider,
481
-				$c->get(\OCP\IConfig::class),
482
-				$c->get(ISecureRandom::class),
483
-				$c->get('LockdownManager'),
484
-				$c->get(LoggerInterface::class),
485
-				$c->get(IEventDispatcher::class),
486
-			);
487
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
488
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
489
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
490
-			});
491
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
492
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
493
-				/** @var \OC\User\User $user */
494
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
495
-			});
496
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
497
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
498
-				/** @var \OC\User\User $user */
499
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
500
-			});
501
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
502
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
503
-				/** @var \OC\User\User $user */
504
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
505
-			});
506
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
507
-				/** @var \OC\User\User $user */
508
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
509
-			});
510
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
511
-				/** @var \OC\User\User $user */
512
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
513
-			});
514
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
515
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
516
-
517
-				/** @var IEventDispatcher $dispatcher */
518
-				$dispatcher = $this->get(IEventDispatcher::class);
519
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
520
-			});
521
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
522
-				/** @var \OC\User\User $user */
523
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
524
-
525
-				/** @var IEventDispatcher $dispatcher */
526
-				$dispatcher = $this->get(IEventDispatcher::class);
527
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
528
-			});
529
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
530
-				/** @var IEventDispatcher $dispatcher */
531
-				$dispatcher = $this->get(IEventDispatcher::class);
532
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
533
-			});
534
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
535
-				/** @var \OC\User\User $user */
536
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
537
-
538
-				/** @var IEventDispatcher $dispatcher */
539
-				$dispatcher = $this->get(IEventDispatcher::class);
540
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
541
-			});
542
-			$userSession->listen('\OC\User', 'logout', function ($user) {
543
-				\OC_Hook::emit('OC_User', 'logout', []);
544
-
545
-				/** @var IEventDispatcher $dispatcher */
546
-				$dispatcher = $this->get(IEventDispatcher::class);
547
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
548
-			});
549
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
550
-				/** @var IEventDispatcher $dispatcher */
551
-				$dispatcher = $this->get(IEventDispatcher::class);
552
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
553
-			});
554
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
555
-				/** @var \OC\User\User $user */
556
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
557
-			});
558
-			return $userSession;
559
-		});
560
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
561
-
562
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
563
-
564
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
565
-
566
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
567
-
568
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
569
-			return new \OC\SystemConfig($config);
570
-		});
571
-
572
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
573
-		$this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
574
-		$this->registerAlias(IAppManager::class, AppManager::class);
575
-
576
-		$this->registerService(IFactory::class, function (Server $c) {
577
-			return new \OC\L10N\Factory(
578
-				$c->get(\OCP\IConfig::class),
579
-				$c->getRequest(),
580
-				$c->get(IUserSession::class),
581
-				$c->get(ICacheFactory::class),
582
-				\OC::$SERVERROOT,
583
-				$c->get(IAppManager::class),
584
-			);
585
-		});
586
-
587
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
588
-
589
-		$this->registerService(ICache::class, function ($c) {
590
-			return new Cache\File();
591
-		});
592
-
593
-		$this->registerService(Factory::class, function (Server $c) {
594
-			$profiler = $c->get(IProfiler::class);
595
-			$arrayCacheFactory = new \OC\Memcache\Factory(fn () => '', $c->get(LoggerInterface::class),
596
-				$profiler,
597
-				ArrayCache::class,
598
-				ArrayCache::class,
599
-				ArrayCache::class
600
-			);
601
-			/** @var SystemConfig $config */
602
-			$config = $c->get(SystemConfig::class);
603
-			/** @var ServerVersion $serverVersion */
604
-			$serverVersion = $c->get(ServerVersion::class);
605
-
606
-			if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
607
-				$logQuery = $config->getValue('log_query');
608
-				$prefixClosure = function () use ($logQuery, $serverVersion): ?string {
609
-					if (!$logQuery) {
610
-						try {
611
-							$v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(true);
612
-						} catch (\Doctrine\DBAL\Exception $e) {
613
-							// Database service probably unavailable
614
-							// Probably related to https://github.com/nextcloud/server/issues/37424
615
-							return null;
616
-						}
617
-					} else {
618
-						// If the log_query is enabled, we can not get the app versions
619
-						// as that does a query, which will be logged and the logging
620
-						// depends on redis and here we are back again in the same function.
621
-						$v = [
622
-							'log_query' => 'enabled',
623
-						];
624
-					}
625
-					$v['core'] = implode(',', $serverVersion->getVersion());
626
-					$version = implode(',', array_keys($v)) . implode(',', $v);
627
-					$instanceId = \OC_Util::getInstanceId();
628
-					$path = \OC::$SERVERROOT;
629
-					return md5($instanceId . '-' . $version . '-' . $path);
630
-				};
631
-				return new \OC\Memcache\Factory($prefixClosure,
632
-					$c->get(LoggerInterface::class),
633
-					$profiler,
634
-					/** @psalm-taint-escape callable */
635
-					$config->getValue('memcache.local', null),
636
-					/** @psalm-taint-escape callable */
637
-					$config->getValue('memcache.distributed', null),
638
-					/** @psalm-taint-escape callable */
639
-					$config->getValue('memcache.locking', null),
640
-					/** @psalm-taint-escape callable */
641
-					$config->getValue('redis_log_file')
642
-				);
643
-			}
644
-			return $arrayCacheFactory;
645
-		});
646
-		$this->registerAlias(ICacheFactory::class, Factory::class);
647
-
648
-		$this->registerService('RedisFactory', function (Server $c) {
649
-			$systemConfig = $c->get(SystemConfig::class);
650
-			return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
651
-		});
652
-
653
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
654
-			$l10n = $this->get(IFactory::class)->get('lib');
655
-			return new \OC\Activity\Manager(
656
-				$c->getRequest(),
657
-				$c->get(IUserSession::class),
658
-				$c->get(\OCP\IConfig::class),
659
-				$c->get(IValidator::class),
660
-				$c->get(IRichTextFormatter::class),
661
-				$l10n
662
-			);
663
-		});
664
-
665
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
666
-			return new \OC\Activity\EventMerger(
667
-				$c->getL10N('lib')
668
-			);
669
-		});
670
-		$this->registerAlias(IValidator::class, Validator::class);
671
-
672
-		$this->registerService(AvatarManager::class, function (Server $c) {
673
-			return new AvatarManager(
674
-				$c->get(IUserSession::class),
675
-				$c->get(\OC\User\Manager::class),
676
-				$c->getAppDataDir('avatar'),
677
-				$c->getL10N('lib'),
678
-				$c->get(LoggerInterface::class),
679
-				$c->get(\OCP\IConfig::class),
680
-				$c->get(IAccountManager::class),
681
-				$c->get(KnownUserService::class)
682
-			);
683
-		});
684
-
685
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
686
-
687
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
688
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
689
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
690
-
691
-		/** Only used by the PsrLoggerAdapter should not be used by apps */
692
-		$this->registerService(\OC\Log::class, function (Server $c) {
693
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
694
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
695
-			$logger = $factory->get($logType);
696
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
697
-
698
-			return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
699
-		});
700
-		// PSR-3 logger
701
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
702
-
703
-		$this->registerService(ILogFactory::class, function (Server $c) {
704
-			return new LogFactory($c, $this->get(SystemConfig::class));
705
-		});
706
-
707
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
708
-
709
-		$this->registerService(Router::class, function (Server $c) {
710
-			$cacheFactory = $c->get(ICacheFactory::class);
711
-			if ($cacheFactory->isLocalCacheAvailable()) {
712
-				$router = $c->resolve(CachingRouter::class);
713
-			} else {
714
-				$router = $c->resolve(Router::class);
715
-			}
716
-			return $router;
717
-		});
718
-		$this->registerAlias(IRouter::class, Router::class);
719
-
720
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
721
-			$config = $c->get(\OCP\IConfig::class);
722
-			if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
723
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
724
-					$c->get(AllConfig::class),
725
-					$this->get(ICacheFactory::class),
726
-					new \OC\AppFramework\Utility\TimeFactory()
727
-				);
728
-			} else {
729
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
730
-					$c->get(AllConfig::class),
731
-					$c->get(IDBConnection::class),
732
-					new \OC\AppFramework\Utility\TimeFactory()
733
-				);
734
-			}
735
-
736
-			return $backend;
737
-		});
738
-
739
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
740
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
741
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
742
-
743
-		$this->registerAlias(ICrypto::class, Crypto::class);
744
-
745
-		$this->registerAlias(IHasher::class, Hasher::class);
746
-
747
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
748
-
749
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
750
-		$this->registerService(Connection::class, function (Server $c) {
751
-			$systemConfig = $c->get(SystemConfig::class);
752
-			$factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
753
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
754
-			if (!$factory->isValidType($type)) {
755
-				throw new \OC\DatabaseException('Invalid database type');
756
-			}
757
-			$connection = $factory->getConnection($type, []);
758
-			return $connection;
759
-		});
760
-
761
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
762
-		$this->registerAlias(IClientService::class, ClientService::class);
763
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
764
-			return new NegativeDnsCache(
765
-				$c->get(ICacheFactory::class),
766
-			);
767
-		});
768
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
769
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
770
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
771
-		});
772
-
773
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
774
-			$queryLogger = new QueryLogger();
775
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
776
-				// In debug mode, module is being activated by default
777
-				$queryLogger->activate();
778
-			}
779
-			return $queryLogger;
780
-		});
781
-
782
-		$this->registerAlias(ITempManager::class, TempManager::class);
783
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
784
-
785
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
786
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
787
-
788
-			return new DateTimeFormatter(
789
-				$c->get(IDateTimeZone::class)->getTimeZone(),
790
-				$c->getL10N('lib', $language)
791
-			);
792
-		});
793
-
794
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
795
-			$mountCache = $c->get(UserMountCache::class);
796
-			$listener = new UserMountCacheListener($mountCache);
797
-			$listener->listen($c->get(IUserManager::class));
798
-			return $mountCache;
799
-		});
800
-
801
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
802
-			$loader = $c->get(IStorageFactory::class);
803
-			$mountCache = $c->get(IUserMountCache::class);
804
-			$eventLogger = $c->get(IEventLogger::class);
805
-			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
806
-
807
-			// builtin providers
808
-
809
-			$config = $c->get(\OCP\IConfig::class);
810
-			$logger = $c->get(LoggerInterface::class);
811
-			$objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
812
-			$manager->registerProvider(new CacheMountProvider($config));
813
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
814
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
815
-			$manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
816
-			$manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
817
-
818
-			return $manager;
819
-		});
820
-
821
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
822
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
823
-			if ($busClass) {
824
-				[$app, $class] = explode('::', $busClass, 2);
825
-				if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
826
-					$c->get(IAppManager::class)->loadApp($app);
827
-					return $c->get($class);
828
-				} else {
829
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
830
-				}
831
-			} else {
832
-				$jobList = $c->get(IJobList::class);
833
-				return new CronBus($jobList);
834
-			}
835
-		});
836
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
837
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
838
-		$this->registerAlias(IThrottler::class, Throttler::class);
839
-
840
-		$this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
841
-			$config = $c->get(\OCP\IConfig::class);
842
-			if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
843
-				&& ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
844
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
845
-			} else {
846
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
847
-			}
848
-
849
-			return $backend;
850
-		});
851
-
852
-		$this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
853
-		$this->registerService(Checker::class, function (ContainerInterface $c) {
854
-			// IConfig requires a working database. This code
855
-			// might however be called when Nextcloud is not yet setup.
856
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
857
-				$config = $c->get(\OCP\IConfig::class);
858
-				$appConfig = $c->get(\OCP\IAppConfig::class);
859
-			} else {
860
-				$config = null;
861
-				$appConfig = null;
862
-			}
863
-
864
-			return new Checker(
865
-				$c->get(ServerVersion::class),
866
-				$c->get(EnvironmentHelper::class),
867
-				new FileAccessHelper(),
868
-				new AppLocator(),
869
-				$config,
870
-				$appConfig,
871
-				$c->get(ICacheFactory::class),
872
-				$c->get(IAppManager::class),
873
-				$c->get(IMimeTypeDetector::class)
874
-			);
875
-		});
876
-		$this->registerService(Request::class, function (ContainerInterface $c) {
877
-			if (isset($this['urlParams'])) {
878
-				$urlParams = $this['urlParams'];
879
-			} else {
880
-				$urlParams = [];
881
-			}
882
-
883
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
884
-				&& in_array('fakeinput', stream_get_wrappers())
885
-			) {
886
-				$stream = 'fakeinput://data';
887
-			} else {
888
-				$stream = 'php://input';
889
-			}
890
-
891
-			return new Request(
892
-				[
893
-					'get' => $_GET,
894
-					'post' => $_POST,
895
-					'files' => $_FILES,
896
-					'server' => $_SERVER,
897
-					'env' => $_ENV,
898
-					'cookies' => $_COOKIE,
899
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
900
-						? $_SERVER['REQUEST_METHOD']
901
-						: '',
902
-					'urlParams' => $urlParams,
903
-				],
904
-				$this->get(IRequestId::class),
905
-				$this->get(\OCP\IConfig::class),
906
-				$this->get(CsrfTokenManager::class),
907
-				$stream
908
-			);
909
-		});
910
-		$this->registerAlias(\OCP\IRequest::class, Request::class);
911
-
912
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
913
-			return new RequestId(
914
-				$_SERVER['UNIQUE_ID'] ?? '',
915
-				$this->get(ISecureRandom::class)
916
-			);
917
-		});
918
-
919
-		$this->registerService(IMailer::class, function (Server $c) {
920
-			return new Mailer(
921
-				$c->get(\OCP\IConfig::class),
922
-				$c->get(LoggerInterface::class),
923
-				$c->get(Defaults::class),
924
-				$c->get(IURLGenerator::class),
925
-				$c->getL10N('lib'),
926
-				$c->get(IEventDispatcher::class),
927
-				$c->get(IFactory::class)
928
-			);
929
-		});
930
-
931
-		/** @since 30.0.0 */
932
-		$this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
933
-
934
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
935
-			$config = $c->get(\OCP\IConfig::class);
936
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
937
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
938
-				return new NullLDAPProviderFactory($this);
939
-			}
940
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
941
-			return new $factoryClass($this);
942
-		});
943
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
944
-			$factory = $c->get(ILDAPProviderFactory::class);
945
-			return $factory->getLDAPProvider();
946
-		});
947
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
948
-			$ini = $c->get(IniGetWrapper::class);
949
-			$config = $c->get(\OCP\IConfig::class);
950
-			$ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
951
-			if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
952
-				/** @var \OC\Memcache\Factory $memcacheFactory */
953
-				$memcacheFactory = $c->get(ICacheFactory::class);
954
-				$memcache = $memcacheFactory->createLocking('lock');
955
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
956
-					$timeFactory = $c->get(ITimeFactory::class);
957
-					return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
958
-				}
959
-				return new DBLockingProvider(
960
-					$c->get(IDBConnection::class),
961
-					new TimeFactory(),
962
-					$ttl,
963
-					!\OC::$CLI
964
-				);
965
-			}
966
-			return new NoopLockingProvider();
967
-		});
968
-
969
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
970
-			return new LockManager();
971
-		});
972
-
973
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
974
-		$this->registerService(SetupManager::class, function ($c) {
975
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
976
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
977
-		});
978
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
979
-
980
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
981
-			return new \OC\Files\Type\Detection(
982
-				$c->get(IURLGenerator::class),
983
-				$c->get(LoggerInterface::class),
984
-				\OC::$configDir,
985
-				\OC::$SERVERROOT . '/resources/config/'
986
-			);
987
-		});
988
-
989
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
990
-		$this->registerService(BundleFetcher::class, function () {
991
-			return new BundleFetcher($this->getL10N('lib'));
992
-		});
993
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
994
-
995
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
996
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
997
-			$manager->registerCapability(function () use ($c) {
998
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
999
-			});
1000
-			$manager->registerCapability(function () use ($c) {
1001
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1002
-			});
1003
-			return $manager;
1004
-		});
1005
-
1006
-		$this->registerService(ICommentsManager::class, function (Server $c) {
1007
-			$config = $c->get(\OCP\IConfig::class);
1008
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1009
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
1010
-			$factory = new $factoryClass($this);
1011
-			$manager = $factory->getManager();
1012
-
1013
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1014
-				$manager = $c->get(IUserManager::class);
1015
-				$userDisplayName = $manager->getDisplayName($id);
1016
-				if ($userDisplayName === null) {
1017
-					$l = $c->get(IFactory::class)->get('core');
1018
-					return $l->t('Unknown account');
1019
-				}
1020
-				return $userDisplayName;
1021
-			});
1022
-
1023
-			return $manager;
1024
-		});
1025
-
1026
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1027
-		$this->registerService('ThemingDefaults', function (Server $c) {
1028
-			try {
1029
-				$classExists = class_exists('OCA\Theming\ThemingDefaults');
1030
-			} catch (\OCP\AutoloadNotAllowedException $e) {
1031
-				// App disabled or in maintenance mode
1032
-				$classExists = false;
1033
-			}
1034
-
1035
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1036
-				$backgroundService = new BackgroundService(
1037
-					$c->get(IRootFolder::class),
1038
-					$c->getAppDataDir('theming'),
1039
-					$c->get(IAppConfig::class),
1040
-					$c->get(\OCP\IConfig::class),
1041
-					$c->get(ISession::class)->get('user_id'),
1042
-				);
1043
-				$imageManager = new ImageManager(
1044
-					$c->get(\OCP\IConfig::class),
1045
-					$c->getAppDataDir('theming'),
1046
-					$c->get(IURLGenerator::class),
1047
-					$c->get(ICacheFactory::class),
1048
-					$c->get(LoggerInterface::class),
1049
-					$c->get(ITempManager::class),
1050
-					$backgroundService,
1051
-				);
1052
-				return new ThemingDefaults(
1053
-					$c->get(\OCP\IConfig::class),
1054
-					$c->get(\OCP\IAppConfig::class),
1055
-					$c->getL10N('theming'),
1056
-					$c->get(IUserSession::class),
1057
-					$c->get(IURLGenerator::class),
1058
-					$c->get(ICacheFactory::class),
1059
-					new Util($c->get(ServerVersion::class), $c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1060
-					$imageManager,
1061
-					$c->get(IAppManager::class),
1062
-					$c->get(INavigationManager::class),
1063
-					$backgroundService,
1064
-				);
1065
-			}
1066
-			return new \OC_Defaults();
1067
-		});
1068
-		$this->registerService(JSCombiner::class, function (Server $c) {
1069
-			return new JSCombiner(
1070
-				$c->getAppDataDir('js'),
1071
-				$c->get(IURLGenerator::class),
1072
-				$this->get(ICacheFactory::class),
1073
-				$c->get(SystemConfig::class),
1074
-				$c->get(LoggerInterface::class)
1075
-			);
1076
-		});
1077
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1078
-
1079
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1080
-			// FIXME: Instantiated here due to cyclic dependency
1081
-			$request = new Request(
1082
-				[
1083
-					'get' => $_GET,
1084
-					'post' => $_POST,
1085
-					'files' => $_FILES,
1086
-					'server' => $_SERVER,
1087
-					'env' => $_ENV,
1088
-					'cookies' => $_COOKIE,
1089
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1090
-						? $_SERVER['REQUEST_METHOD']
1091
-						: null,
1092
-				],
1093
-				$c->get(IRequestId::class),
1094
-				$c->get(\OCP\IConfig::class)
1095
-			);
1096
-
1097
-			return new CryptoWrapper(
1098
-				$c->get(ICrypto::class),
1099
-				$c->get(ISecureRandom::class),
1100
-				$request
1101
-			);
1102
-		});
1103
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1104
-			return new SessionStorage($c->get(ISession::class));
1105
-		});
1106
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1107
-
1108
-		$this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1109
-			$config = $c->get(\OCP\IConfig::class);
1110
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1111
-			/** @var \OCP\Share\IProviderFactory $factory */
1112
-			return $c->get($factoryClass);
1113
-		});
1114
-
1115
-		$this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1116
-
1117
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1118
-			$instance = new Collaboration\Collaborators\Search($c);
1119
-
1120
-			// register default plugins
1121
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1122
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1123
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1124
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1125
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1126
-
1127
-			return $instance;
1128
-		});
1129
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1130
-
1131
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1132
-
1133
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1134
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1135
-
1136
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1137
-		$this->registerAlias(ITeamManager::class, TeamManager::class);
1138
-
1139
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1140
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1141
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1142
-			return new \OC\Files\AppData\Factory(
1143
-				$c->get(IRootFolder::class),
1144
-				$c->get(SystemConfig::class)
1145
-			);
1146
-		});
1147
-
1148
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1149
-			return new LockdownManager(function () use ($c) {
1150
-				return $c->get(ISession::class);
1151
-			});
1152
-		});
1153
-
1154
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1155
-			return new DiscoveryService(
1156
-				$c->get(ICacheFactory::class),
1157
-				$c->get(IClientService::class)
1158
-			);
1159
-		});
1160
-		$this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1161
-
1162
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1163
-			return new CloudIdManager(
1164
-				$c->get(\OCP\Contacts\IManager::class),
1165
-				$c->get(IURLGenerator::class),
1166
-				$c->get(IUserManager::class),
1167
-				$c->get(ICacheFactory::class),
1168
-				$c->get(IEventDispatcher::class),
1169
-			);
1170
-		});
1171
-
1172
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1173
-		$this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1174
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1175
-			return new CloudFederationFactory();
1176
-		});
252
+    /** @var string */
253
+    private $webRoot;
254
+
255
+    /**
256
+     * @param string $webRoot
257
+     * @param \OC\Config $config
258
+     */
259
+    public function __construct($webRoot, \OC\Config $config) {
260
+        parent::__construct();
261
+        $this->webRoot = $webRoot;
262
+
263
+        // To find out if we are running from CLI or not
264
+        $this->registerParameter('isCLI', \OC::$CLI);
265
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
266
+
267
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
268
+            return $c;
269
+        });
270
+        $this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
271
+
272
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
273
+
274
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
275
+
276
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
277
+
278
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
279
+
280
+        $this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
281
+
282
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
283
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
284
+        $this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
285
+
286
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
287
+
288
+        $this->registerService(View::class, function (Server $c) {
289
+            return new View();
290
+        }, false);
291
+
292
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
293
+            return new PreviewManager(
294
+                $c->get(\OCP\IConfig::class),
295
+                $c->get(IRootFolder::class),
296
+                new \OC\Preview\Storage\Root(
297
+                    $c->get(IRootFolder::class),
298
+                    $c->get(SystemConfig::class)
299
+                ),
300
+                $c->get(IEventDispatcher::class),
301
+                $c->get(GeneratorHelper::class),
302
+                $c->get(ISession::class)->get('user_id'),
303
+                $c->get(Coordinator::class),
304
+                $c->get(IServerContainer::class),
305
+                $c->get(IBinaryFinder::class),
306
+                $c->get(IMagickSupport::class)
307
+            );
308
+        });
309
+        $this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
310
+
311
+        $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
312
+            return new \OC\Preview\Watcher(
313
+                new \OC\Preview\Storage\Root(
314
+                    $c->get(IRootFolder::class),
315
+                    $c->get(SystemConfig::class)
316
+                )
317
+            );
318
+        });
319
+
320
+        $this->registerService(IProfiler::class, function (Server $c) {
321
+            return new Profiler($c->get(SystemConfig::class));
322
+        });
323
+
324
+        $this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
325
+            $view = new View();
326
+            $util = new Encryption\Util(
327
+                $view,
328
+                $c->get(IUserManager::class),
329
+                $c->get(IGroupManager::class),
330
+                $c->get(\OCP\IConfig::class)
331
+            );
332
+            return new Encryption\Manager(
333
+                $c->get(\OCP\IConfig::class),
334
+                $c->get(LoggerInterface::class),
335
+                $c->getL10N('core'),
336
+                new View(),
337
+                $util,
338
+                new ArrayCache()
339
+            );
340
+        });
341
+        $this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
342
+
343
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
344
+            $util = new Encryption\Util(
345
+                new View(),
346
+                $c->get(IUserManager::class),
347
+                $c->get(IGroupManager::class),
348
+                $c->get(\OCP\IConfig::class)
349
+            );
350
+            return new Encryption\File(
351
+                $util,
352
+                $c->get(IRootFolder::class),
353
+                $c->get(\OCP\Share\IManager::class)
354
+            );
355
+        });
356
+
357
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
358
+            $view = new View();
359
+            $util = new Encryption\Util(
360
+                $view,
361
+                $c->get(IUserManager::class),
362
+                $c->get(IGroupManager::class),
363
+                $c->get(\OCP\IConfig::class)
364
+            );
365
+
366
+            return new Encryption\Keys\Storage(
367
+                $view,
368
+                $util,
369
+                $c->get(ICrypto::class),
370
+                $c->get(\OCP\IConfig::class)
371
+            );
372
+        });
373
+
374
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
375
+
376
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
377
+            /** @var \OCP\IConfig $config */
378
+            $config = $c->get(\OCP\IConfig::class);
379
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
380
+            return new $factoryClass($this);
381
+        });
382
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
383
+            return $c->get('SystemTagManagerFactory')->getManager();
384
+        });
385
+        /** @deprecated 19.0.0 */
386
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
387
+
388
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
389
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
390
+        });
391
+        $this->registerAlias(IFileAccess::class, FileAccess::class);
392
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
393
+            $manager = \OC\Files\Filesystem::getMountManager();
394
+            $view = new View();
395
+            /** @var IUserSession $userSession */
396
+            $userSession = $c->get(IUserSession::class);
397
+            $root = new Root(
398
+                $manager,
399
+                $view,
400
+                $userSession->getUser(),
401
+                $c->get(IUserMountCache::class),
402
+                $this->get(LoggerInterface::class),
403
+                $this->get(IUserManager::class),
404
+                $this->get(IEventDispatcher::class),
405
+                $this->get(ICacheFactory::class),
406
+            );
407
+
408
+            $previewConnector = new \OC\Preview\WatcherConnector(
409
+                $root,
410
+                $c->get(SystemConfig::class),
411
+                $this->get(IEventDispatcher::class)
412
+            );
413
+            $previewConnector->connectWatcher();
414
+
415
+            return $root;
416
+        });
417
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
418
+            return new HookConnector(
419
+                $c->get(IRootFolder::class),
420
+                new View(),
421
+                $c->get(IEventDispatcher::class),
422
+                $c->get(LoggerInterface::class)
423
+            );
424
+        });
425
+
426
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
427
+            return new LazyRoot(function () use ($c) {
428
+                return $c->get('RootFolder');
429
+            });
430
+        });
431
+
432
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
433
+
434
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
435
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
436
+        });
437
+
438
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
439
+            $groupManager = new \OC\Group\Manager(
440
+                $this->get(IUserManager::class),
441
+                $this->get(IEventDispatcher::class),
442
+                $this->get(LoggerInterface::class),
443
+                $this->get(ICacheFactory::class),
444
+                $this->get(IRemoteAddress::class),
445
+            );
446
+            return $groupManager;
447
+        });
448
+
449
+        $this->registerService(Store::class, function (ContainerInterface $c) {
450
+            $session = $c->get(ISession::class);
451
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
452
+                $tokenProvider = $c->get(IProvider::class);
453
+            } else {
454
+                $tokenProvider = null;
455
+            }
456
+            $logger = $c->get(LoggerInterface::class);
457
+            $crypto = $c->get(ICrypto::class);
458
+            return new Store($session, $logger, $crypto, $tokenProvider);
459
+        });
460
+        $this->registerAlias(IStore::class, Store::class);
461
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
462
+        $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
463
+
464
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
465
+            $manager = $c->get(IUserManager::class);
466
+            $session = new \OC\Session\Memory();
467
+            $timeFactory = new TimeFactory();
468
+            // Token providers might require a working database. This code
469
+            // might however be called when Nextcloud is not yet setup.
470
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
471
+                $provider = $c->get(IProvider::class);
472
+            } else {
473
+                $provider = null;
474
+            }
475
+
476
+            $userSession = new \OC\User\Session(
477
+                $manager,
478
+                $session,
479
+                $timeFactory,
480
+                $provider,
481
+                $c->get(\OCP\IConfig::class),
482
+                $c->get(ISecureRandom::class),
483
+                $c->get('LockdownManager'),
484
+                $c->get(LoggerInterface::class),
485
+                $c->get(IEventDispatcher::class),
486
+            );
487
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
488
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
489
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
490
+            });
491
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
492
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
493
+                /** @var \OC\User\User $user */
494
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
495
+            });
496
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
497
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
498
+                /** @var \OC\User\User $user */
499
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
500
+            });
501
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
502
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
503
+                /** @var \OC\User\User $user */
504
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
505
+            });
506
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
507
+                /** @var \OC\User\User $user */
508
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
509
+            });
510
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
511
+                /** @var \OC\User\User $user */
512
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
513
+            });
514
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
515
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
516
+
517
+                /** @var IEventDispatcher $dispatcher */
518
+                $dispatcher = $this->get(IEventDispatcher::class);
519
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
520
+            });
521
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
522
+                /** @var \OC\User\User $user */
523
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
524
+
525
+                /** @var IEventDispatcher $dispatcher */
526
+                $dispatcher = $this->get(IEventDispatcher::class);
527
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
528
+            });
529
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
530
+                /** @var IEventDispatcher $dispatcher */
531
+                $dispatcher = $this->get(IEventDispatcher::class);
532
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
533
+            });
534
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
535
+                /** @var \OC\User\User $user */
536
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
537
+
538
+                /** @var IEventDispatcher $dispatcher */
539
+                $dispatcher = $this->get(IEventDispatcher::class);
540
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
541
+            });
542
+            $userSession->listen('\OC\User', 'logout', function ($user) {
543
+                \OC_Hook::emit('OC_User', 'logout', []);
544
+
545
+                /** @var IEventDispatcher $dispatcher */
546
+                $dispatcher = $this->get(IEventDispatcher::class);
547
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
548
+            });
549
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
550
+                /** @var IEventDispatcher $dispatcher */
551
+                $dispatcher = $this->get(IEventDispatcher::class);
552
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
553
+            });
554
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
555
+                /** @var \OC\User\User $user */
556
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
557
+            });
558
+            return $userSession;
559
+        });
560
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
561
+
562
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
563
+
564
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
565
+
566
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
567
+
568
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
569
+            return new \OC\SystemConfig($config);
570
+        });
571
+
572
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
573
+        $this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
574
+        $this->registerAlias(IAppManager::class, AppManager::class);
575
+
576
+        $this->registerService(IFactory::class, function (Server $c) {
577
+            return new \OC\L10N\Factory(
578
+                $c->get(\OCP\IConfig::class),
579
+                $c->getRequest(),
580
+                $c->get(IUserSession::class),
581
+                $c->get(ICacheFactory::class),
582
+                \OC::$SERVERROOT,
583
+                $c->get(IAppManager::class),
584
+            );
585
+        });
586
+
587
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
588
+
589
+        $this->registerService(ICache::class, function ($c) {
590
+            return new Cache\File();
591
+        });
592
+
593
+        $this->registerService(Factory::class, function (Server $c) {
594
+            $profiler = $c->get(IProfiler::class);
595
+            $arrayCacheFactory = new \OC\Memcache\Factory(fn () => '', $c->get(LoggerInterface::class),
596
+                $profiler,
597
+                ArrayCache::class,
598
+                ArrayCache::class,
599
+                ArrayCache::class
600
+            );
601
+            /** @var SystemConfig $config */
602
+            $config = $c->get(SystemConfig::class);
603
+            /** @var ServerVersion $serverVersion */
604
+            $serverVersion = $c->get(ServerVersion::class);
605
+
606
+            if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
607
+                $logQuery = $config->getValue('log_query');
608
+                $prefixClosure = function () use ($logQuery, $serverVersion): ?string {
609
+                    if (!$logQuery) {
610
+                        try {
611
+                            $v = \OCP\Server::get(IAppConfig::class)->getAppInstalledVersions(true);
612
+                        } catch (\Doctrine\DBAL\Exception $e) {
613
+                            // Database service probably unavailable
614
+                            // Probably related to https://github.com/nextcloud/server/issues/37424
615
+                            return null;
616
+                        }
617
+                    } else {
618
+                        // If the log_query is enabled, we can not get the app versions
619
+                        // as that does a query, which will be logged and the logging
620
+                        // depends on redis and here we are back again in the same function.
621
+                        $v = [
622
+                            'log_query' => 'enabled',
623
+                        ];
624
+                    }
625
+                    $v['core'] = implode(',', $serverVersion->getVersion());
626
+                    $version = implode(',', array_keys($v)) . implode(',', $v);
627
+                    $instanceId = \OC_Util::getInstanceId();
628
+                    $path = \OC::$SERVERROOT;
629
+                    return md5($instanceId . '-' . $version . '-' . $path);
630
+                };
631
+                return new \OC\Memcache\Factory($prefixClosure,
632
+                    $c->get(LoggerInterface::class),
633
+                    $profiler,
634
+                    /** @psalm-taint-escape callable */
635
+                    $config->getValue('memcache.local', null),
636
+                    /** @psalm-taint-escape callable */
637
+                    $config->getValue('memcache.distributed', null),
638
+                    /** @psalm-taint-escape callable */
639
+                    $config->getValue('memcache.locking', null),
640
+                    /** @psalm-taint-escape callable */
641
+                    $config->getValue('redis_log_file')
642
+                );
643
+            }
644
+            return $arrayCacheFactory;
645
+        });
646
+        $this->registerAlias(ICacheFactory::class, Factory::class);
647
+
648
+        $this->registerService('RedisFactory', function (Server $c) {
649
+            $systemConfig = $c->get(SystemConfig::class);
650
+            return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
651
+        });
652
+
653
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
654
+            $l10n = $this->get(IFactory::class)->get('lib');
655
+            return new \OC\Activity\Manager(
656
+                $c->getRequest(),
657
+                $c->get(IUserSession::class),
658
+                $c->get(\OCP\IConfig::class),
659
+                $c->get(IValidator::class),
660
+                $c->get(IRichTextFormatter::class),
661
+                $l10n
662
+            );
663
+        });
664
+
665
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
666
+            return new \OC\Activity\EventMerger(
667
+                $c->getL10N('lib')
668
+            );
669
+        });
670
+        $this->registerAlias(IValidator::class, Validator::class);
671
+
672
+        $this->registerService(AvatarManager::class, function (Server $c) {
673
+            return new AvatarManager(
674
+                $c->get(IUserSession::class),
675
+                $c->get(\OC\User\Manager::class),
676
+                $c->getAppDataDir('avatar'),
677
+                $c->getL10N('lib'),
678
+                $c->get(LoggerInterface::class),
679
+                $c->get(\OCP\IConfig::class),
680
+                $c->get(IAccountManager::class),
681
+                $c->get(KnownUserService::class)
682
+            );
683
+        });
684
+
685
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
686
+
687
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
688
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
689
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
690
+
691
+        /** Only used by the PsrLoggerAdapter should not be used by apps */
692
+        $this->registerService(\OC\Log::class, function (Server $c) {
693
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
694
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
695
+            $logger = $factory->get($logType);
696
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
697
+
698
+            return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
699
+        });
700
+        // PSR-3 logger
701
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
702
+
703
+        $this->registerService(ILogFactory::class, function (Server $c) {
704
+            return new LogFactory($c, $this->get(SystemConfig::class));
705
+        });
706
+
707
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
708
+
709
+        $this->registerService(Router::class, function (Server $c) {
710
+            $cacheFactory = $c->get(ICacheFactory::class);
711
+            if ($cacheFactory->isLocalCacheAvailable()) {
712
+                $router = $c->resolve(CachingRouter::class);
713
+            } else {
714
+                $router = $c->resolve(Router::class);
715
+            }
716
+            return $router;
717
+        });
718
+        $this->registerAlias(IRouter::class, Router::class);
719
+
720
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
721
+            $config = $c->get(\OCP\IConfig::class);
722
+            if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
723
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
724
+                    $c->get(AllConfig::class),
725
+                    $this->get(ICacheFactory::class),
726
+                    new \OC\AppFramework\Utility\TimeFactory()
727
+                );
728
+            } else {
729
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
730
+                    $c->get(AllConfig::class),
731
+                    $c->get(IDBConnection::class),
732
+                    new \OC\AppFramework\Utility\TimeFactory()
733
+                );
734
+            }
735
+
736
+            return $backend;
737
+        });
738
+
739
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
740
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
741
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
742
+
743
+        $this->registerAlias(ICrypto::class, Crypto::class);
744
+
745
+        $this->registerAlias(IHasher::class, Hasher::class);
746
+
747
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
748
+
749
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
750
+        $this->registerService(Connection::class, function (Server $c) {
751
+            $systemConfig = $c->get(SystemConfig::class);
752
+            $factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
753
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
754
+            if (!$factory->isValidType($type)) {
755
+                throw new \OC\DatabaseException('Invalid database type');
756
+            }
757
+            $connection = $factory->getConnection($type, []);
758
+            return $connection;
759
+        });
760
+
761
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
762
+        $this->registerAlias(IClientService::class, ClientService::class);
763
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
764
+            return new NegativeDnsCache(
765
+                $c->get(ICacheFactory::class),
766
+            );
767
+        });
768
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
769
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
770
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
771
+        });
772
+
773
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
774
+            $queryLogger = new QueryLogger();
775
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
776
+                // In debug mode, module is being activated by default
777
+                $queryLogger->activate();
778
+            }
779
+            return $queryLogger;
780
+        });
781
+
782
+        $this->registerAlias(ITempManager::class, TempManager::class);
783
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
784
+
785
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
786
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
787
+
788
+            return new DateTimeFormatter(
789
+                $c->get(IDateTimeZone::class)->getTimeZone(),
790
+                $c->getL10N('lib', $language)
791
+            );
792
+        });
793
+
794
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
795
+            $mountCache = $c->get(UserMountCache::class);
796
+            $listener = new UserMountCacheListener($mountCache);
797
+            $listener->listen($c->get(IUserManager::class));
798
+            return $mountCache;
799
+        });
800
+
801
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
802
+            $loader = $c->get(IStorageFactory::class);
803
+            $mountCache = $c->get(IUserMountCache::class);
804
+            $eventLogger = $c->get(IEventLogger::class);
805
+            $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
806
+
807
+            // builtin providers
808
+
809
+            $config = $c->get(\OCP\IConfig::class);
810
+            $logger = $c->get(LoggerInterface::class);
811
+            $objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
812
+            $manager->registerProvider(new CacheMountProvider($config));
813
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
814
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
815
+            $manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
816
+            $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
817
+
818
+            return $manager;
819
+        });
820
+
821
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
822
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
823
+            if ($busClass) {
824
+                [$app, $class] = explode('::', $busClass, 2);
825
+                if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
826
+                    $c->get(IAppManager::class)->loadApp($app);
827
+                    return $c->get($class);
828
+                } else {
829
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
830
+                }
831
+            } else {
832
+                $jobList = $c->get(IJobList::class);
833
+                return new CronBus($jobList);
834
+            }
835
+        });
836
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
837
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
838
+        $this->registerAlias(IThrottler::class, Throttler::class);
839
+
840
+        $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
841
+            $config = $c->get(\OCP\IConfig::class);
842
+            if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
843
+                && ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
844
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
845
+            } else {
846
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
847
+            }
848
+
849
+            return $backend;
850
+        });
851
+
852
+        $this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
853
+        $this->registerService(Checker::class, function (ContainerInterface $c) {
854
+            // IConfig requires a working database. This code
855
+            // might however be called when Nextcloud is not yet setup.
856
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
857
+                $config = $c->get(\OCP\IConfig::class);
858
+                $appConfig = $c->get(\OCP\IAppConfig::class);
859
+            } else {
860
+                $config = null;
861
+                $appConfig = null;
862
+            }
863
+
864
+            return new Checker(
865
+                $c->get(ServerVersion::class),
866
+                $c->get(EnvironmentHelper::class),
867
+                new FileAccessHelper(),
868
+                new AppLocator(),
869
+                $config,
870
+                $appConfig,
871
+                $c->get(ICacheFactory::class),
872
+                $c->get(IAppManager::class),
873
+                $c->get(IMimeTypeDetector::class)
874
+            );
875
+        });
876
+        $this->registerService(Request::class, function (ContainerInterface $c) {
877
+            if (isset($this['urlParams'])) {
878
+                $urlParams = $this['urlParams'];
879
+            } else {
880
+                $urlParams = [];
881
+            }
882
+
883
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
884
+                && in_array('fakeinput', stream_get_wrappers())
885
+            ) {
886
+                $stream = 'fakeinput://data';
887
+            } else {
888
+                $stream = 'php://input';
889
+            }
890
+
891
+            return new Request(
892
+                [
893
+                    'get' => $_GET,
894
+                    'post' => $_POST,
895
+                    'files' => $_FILES,
896
+                    'server' => $_SERVER,
897
+                    'env' => $_ENV,
898
+                    'cookies' => $_COOKIE,
899
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
900
+                        ? $_SERVER['REQUEST_METHOD']
901
+                        : '',
902
+                    'urlParams' => $urlParams,
903
+                ],
904
+                $this->get(IRequestId::class),
905
+                $this->get(\OCP\IConfig::class),
906
+                $this->get(CsrfTokenManager::class),
907
+                $stream
908
+            );
909
+        });
910
+        $this->registerAlias(\OCP\IRequest::class, Request::class);
911
+
912
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
913
+            return new RequestId(
914
+                $_SERVER['UNIQUE_ID'] ?? '',
915
+                $this->get(ISecureRandom::class)
916
+            );
917
+        });
918
+
919
+        $this->registerService(IMailer::class, function (Server $c) {
920
+            return new Mailer(
921
+                $c->get(\OCP\IConfig::class),
922
+                $c->get(LoggerInterface::class),
923
+                $c->get(Defaults::class),
924
+                $c->get(IURLGenerator::class),
925
+                $c->getL10N('lib'),
926
+                $c->get(IEventDispatcher::class),
927
+                $c->get(IFactory::class)
928
+            );
929
+        });
930
+
931
+        /** @since 30.0.0 */
932
+        $this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
933
+
934
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
935
+            $config = $c->get(\OCP\IConfig::class);
936
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
937
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
938
+                return new NullLDAPProviderFactory($this);
939
+            }
940
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
941
+            return new $factoryClass($this);
942
+        });
943
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
944
+            $factory = $c->get(ILDAPProviderFactory::class);
945
+            return $factory->getLDAPProvider();
946
+        });
947
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
948
+            $ini = $c->get(IniGetWrapper::class);
949
+            $config = $c->get(\OCP\IConfig::class);
950
+            $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
951
+            if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
952
+                /** @var \OC\Memcache\Factory $memcacheFactory */
953
+                $memcacheFactory = $c->get(ICacheFactory::class);
954
+                $memcache = $memcacheFactory->createLocking('lock');
955
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
956
+                    $timeFactory = $c->get(ITimeFactory::class);
957
+                    return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
958
+                }
959
+                return new DBLockingProvider(
960
+                    $c->get(IDBConnection::class),
961
+                    new TimeFactory(),
962
+                    $ttl,
963
+                    !\OC::$CLI
964
+                );
965
+            }
966
+            return new NoopLockingProvider();
967
+        });
968
+
969
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
970
+            return new LockManager();
971
+        });
972
+
973
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
974
+        $this->registerService(SetupManager::class, function ($c) {
975
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
976
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
977
+        });
978
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
979
+
980
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
981
+            return new \OC\Files\Type\Detection(
982
+                $c->get(IURLGenerator::class),
983
+                $c->get(LoggerInterface::class),
984
+                \OC::$configDir,
985
+                \OC::$SERVERROOT . '/resources/config/'
986
+            );
987
+        });
988
+
989
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
990
+        $this->registerService(BundleFetcher::class, function () {
991
+            return new BundleFetcher($this->getL10N('lib'));
992
+        });
993
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
994
+
995
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
996
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
997
+            $manager->registerCapability(function () use ($c) {
998
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
999
+            });
1000
+            $manager->registerCapability(function () use ($c) {
1001
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
1002
+            });
1003
+            return $manager;
1004
+        });
1005
+
1006
+        $this->registerService(ICommentsManager::class, function (Server $c) {
1007
+            $config = $c->get(\OCP\IConfig::class);
1008
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
1009
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
1010
+            $factory = new $factoryClass($this);
1011
+            $manager = $factory->getManager();
1012
+
1013
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
1014
+                $manager = $c->get(IUserManager::class);
1015
+                $userDisplayName = $manager->getDisplayName($id);
1016
+                if ($userDisplayName === null) {
1017
+                    $l = $c->get(IFactory::class)->get('core');
1018
+                    return $l->t('Unknown account');
1019
+                }
1020
+                return $userDisplayName;
1021
+            });
1022
+
1023
+            return $manager;
1024
+        });
1025
+
1026
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1027
+        $this->registerService('ThemingDefaults', function (Server $c) {
1028
+            try {
1029
+                $classExists = class_exists('OCA\Theming\ThemingDefaults');
1030
+            } catch (\OCP\AutoloadNotAllowedException $e) {
1031
+                // App disabled or in maintenance mode
1032
+                $classExists = false;
1033
+            }
1034
+
1035
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1036
+                $backgroundService = new BackgroundService(
1037
+                    $c->get(IRootFolder::class),
1038
+                    $c->getAppDataDir('theming'),
1039
+                    $c->get(IAppConfig::class),
1040
+                    $c->get(\OCP\IConfig::class),
1041
+                    $c->get(ISession::class)->get('user_id'),
1042
+                );
1043
+                $imageManager = new ImageManager(
1044
+                    $c->get(\OCP\IConfig::class),
1045
+                    $c->getAppDataDir('theming'),
1046
+                    $c->get(IURLGenerator::class),
1047
+                    $c->get(ICacheFactory::class),
1048
+                    $c->get(LoggerInterface::class),
1049
+                    $c->get(ITempManager::class),
1050
+                    $backgroundService,
1051
+                );
1052
+                return new ThemingDefaults(
1053
+                    $c->get(\OCP\IConfig::class),
1054
+                    $c->get(\OCP\IAppConfig::class),
1055
+                    $c->getL10N('theming'),
1056
+                    $c->get(IUserSession::class),
1057
+                    $c->get(IURLGenerator::class),
1058
+                    $c->get(ICacheFactory::class),
1059
+                    new Util($c->get(ServerVersion::class), $c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
1060
+                    $imageManager,
1061
+                    $c->get(IAppManager::class),
1062
+                    $c->get(INavigationManager::class),
1063
+                    $backgroundService,
1064
+                );
1065
+            }
1066
+            return new \OC_Defaults();
1067
+        });
1068
+        $this->registerService(JSCombiner::class, function (Server $c) {
1069
+            return new JSCombiner(
1070
+                $c->getAppDataDir('js'),
1071
+                $c->get(IURLGenerator::class),
1072
+                $this->get(ICacheFactory::class),
1073
+                $c->get(SystemConfig::class),
1074
+                $c->get(LoggerInterface::class)
1075
+            );
1076
+        });
1077
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1078
+
1079
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1080
+            // FIXME: Instantiated here due to cyclic dependency
1081
+            $request = new Request(
1082
+                [
1083
+                    'get' => $_GET,
1084
+                    'post' => $_POST,
1085
+                    'files' => $_FILES,
1086
+                    'server' => $_SERVER,
1087
+                    'env' => $_ENV,
1088
+                    'cookies' => $_COOKIE,
1089
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1090
+                        ? $_SERVER['REQUEST_METHOD']
1091
+                        : null,
1092
+                ],
1093
+                $c->get(IRequestId::class),
1094
+                $c->get(\OCP\IConfig::class)
1095
+            );
1096
+
1097
+            return new CryptoWrapper(
1098
+                $c->get(ICrypto::class),
1099
+                $c->get(ISecureRandom::class),
1100
+                $request
1101
+            );
1102
+        });
1103
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1104
+            return new SessionStorage($c->get(ISession::class));
1105
+        });
1106
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1107
+
1108
+        $this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1109
+            $config = $c->get(\OCP\IConfig::class);
1110
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1111
+            /** @var \OCP\Share\IProviderFactory $factory */
1112
+            return $c->get($factoryClass);
1113
+        });
1114
+
1115
+        $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1116
+
1117
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1118
+            $instance = new Collaboration\Collaborators\Search($c);
1119
+
1120
+            // register default plugins
1121
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1122
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1123
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1124
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1125
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1126
+
1127
+            return $instance;
1128
+        });
1129
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1130
+
1131
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1132
+
1133
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1134
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1135
+
1136
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1137
+        $this->registerAlias(ITeamManager::class, TeamManager::class);
1138
+
1139
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1140
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1141
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1142
+            return new \OC\Files\AppData\Factory(
1143
+                $c->get(IRootFolder::class),
1144
+                $c->get(SystemConfig::class)
1145
+            );
1146
+        });
1147
+
1148
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1149
+            return new LockdownManager(function () use ($c) {
1150
+                return $c->get(ISession::class);
1151
+            });
1152
+        });
1153
+
1154
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1155
+            return new DiscoveryService(
1156
+                $c->get(ICacheFactory::class),
1157
+                $c->get(IClientService::class)
1158
+            );
1159
+        });
1160
+        $this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1161
+
1162
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1163
+            return new CloudIdManager(
1164
+                $c->get(\OCP\Contacts\IManager::class),
1165
+                $c->get(IURLGenerator::class),
1166
+                $c->get(IUserManager::class),
1167
+                $c->get(ICacheFactory::class),
1168
+                $c->get(IEventDispatcher::class),
1169
+            );
1170
+        });
1171
+
1172
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1173
+        $this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1174
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1175
+            return new CloudFederationFactory();
1176
+        });
1177 1177
 
1178
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1178
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1179 1179
 
1180
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1181
-		$this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1180
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1181
+        $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1182 1182
 
1183
-		$this->registerService(Defaults::class, function (Server $c) {
1184
-			return new Defaults(
1185
-				$c->get('ThemingDefaults')
1186
-			);
1187
-		});
1183
+        $this->registerService(Defaults::class, function (Server $c) {
1184
+            return new Defaults(
1185
+                $c->get('ThemingDefaults')
1186
+            );
1187
+        });
1188 1188
 
1189
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1190
-			return $c->get(\OCP\IUserSession::class)->getSession();
1191
-		}, false);
1189
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1190
+            return $c->get(\OCP\IUserSession::class)->getSession();
1191
+        }, false);
1192 1192
 
1193
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1194
-			return new ShareHelper(
1195
-				$c->get(\OCP\Share\IManager::class)
1196
-			);
1197
-		});
1193
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1194
+            return new ShareHelper(
1195
+                $c->get(\OCP\Share\IManager::class)
1196
+            );
1197
+        });
1198 1198
 
1199
-		$this->registerService(Installer::class, function (ContainerInterface $c) {
1200
-			return new Installer(
1201
-				$c->get(AppFetcher::class),
1202
-				$c->get(IClientService::class),
1203
-				$c->get(ITempManager::class),
1204
-				$c->get(LoggerInterface::class),
1205
-				$c->get(\OCP\IConfig::class),
1206
-				\OC::$CLI
1207
-			);
1208
-		});
1199
+        $this->registerService(Installer::class, function (ContainerInterface $c) {
1200
+            return new Installer(
1201
+                $c->get(AppFetcher::class),
1202
+                $c->get(IClientService::class),
1203
+                $c->get(ITempManager::class),
1204
+                $c->get(LoggerInterface::class),
1205
+                $c->get(\OCP\IConfig::class),
1206
+                \OC::$CLI
1207
+            );
1208
+        });
1209 1209
 
1210
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1211
-			return new ApiFactory($c->get(IClientService::class));
1212
-		});
1210
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1211
+            return new ApiFactory($c->get(IClientService::class));
1212
+        });
1213 1213
 
1214
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1215
-			$memcacheFactory = $c->get(ICacheFactory::class);
1216
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1217
-		});
1214
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1215
+            $memcacheFactory = $c->get(ICacheFactory::class);
1216
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1217
+        });
1218 1218
 
1219
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1220
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1219
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1220
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1221 1221
 
1222
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1222
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1223 1223
 
1224
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1224
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1225 1225
 
1226
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1227
-		$this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1226
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1227
+        $this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1228 1228
 
1229
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1229
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1230 1230
 
1231
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1231
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1232 1232
 
1233
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1233
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1234 1234
 
1235
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1235
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1236 1236
 
1237
-		$this->registerAlias(IBroker::class, Broker::class);
1237
+        $this->registerAlias(IBroker::class, Broker::class);
1238 1238
 
1239
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1239
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1240 1240
 
1241
-		$this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1241
+        $this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1242 1242
 
1243
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1243
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1244 1244
 
1245
-		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1245
+        $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1246 1246
 
1247
-		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1247
+        $this->registerAlias(ITranslationManager::class, TranslationManager::class);
1248 1248
 
1249
-		$this->registerAlias(IConversionManager::class, ConversionManager::class);
1249
+        $this->registerAlias(IConversionManager::class, ConversionManager::class);
1250 1250
 
1251
-		$this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1251
+        $this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1252 1252
 
1253
-		$this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1253
+        $this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1254 1254
 
1255
-		$this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1255
+        $this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1256 1256
 
1257
-		$this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1257
+        $this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1258 1258
 
1259
-		$this->registerAlias(ILimiter::class, Limiter::class);
1259
+        $this->registerAlias(ILimiter::class, Limiter::class);
1260 1260
 
1261
-		$this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1261
+        $this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1262 1262
 
1263
-		$this->registerAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1264
-		$this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1263
+        $this->registerAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1264
+        $this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1265 1265
 
1266
-		$this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1266
+        $this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1267 1267
 
1268
-		$this->registerAlias(IProfileManager::class, ProfileManager::class);
1268
+        $this->registerAlias(IProfileManager::class, ProfileManager::class);
1269 1269
 
1270
-		$this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1270
+        $this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1271 1271
 
1272
-		$this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1272
+        $this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1273 1273
 
1274
-		$this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1274
+        $this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1275 1275
 
1276
-		$this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1276
+        $this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1277 1277
 
1278
-		$this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1279
-
1280
-		$this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1281
-
1282
-		$this->registerAlias(ISignatureManager::class, SignatureManager::class);
1283
-
1284
-		$this->connectDispatcher();
1285
-	}
1286
-
1287
-	public function boot() {
1288
-		/** @var HookConnector $hookConnector */
1289
-		$hookConnector = $this->get(HookConnector::class);
1290
-		$hookConnector->viewToNode();
1291
-	}
1292
-
1293
-	private function connectDispatcher(): void {
1294
-		/** @var IEventDispatcher $eventDispatcher */
1295
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1296
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1297
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1298
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1299
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1300
-
1301
-		FilesMetadataManager::loadListeners($eventDispatcher);
1302
-		GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1303
-	}
1304
-
1305
-	/**
1306
-	 * @return \OCP\Contacts\IManager
1307
-	 * @deprecated 20.0.0
1308
-	 */
1309
-	public function getContactsManager() {
1310
-		return $this->get(\OCP\Contacts\IManager::class);
1311
-	}
1312
-
1313
-	/**
1314
-	 * @return \OC\Encryption\Manager
1315
-	 * @deprecated 20.0.0
1316
-	 */
1317
-	public function getEncryptionManager() {
1318
-		return $this->get(\OCP\Encryption\IManager::class);
1319
-	}
1320
-
1321
-	/**
1322
-	 * @return \OC\Encryption\File
1323
-	 * @deprecated 20.0.0
1324
-	 */
1325
-	public function getEncryptionFilesHelper() {
1326
-		return $this->get(IFile::class);
1327
-	}
1328
-
1329
-	/**
1330
-	 * The current request object holding all information about the request
1331
-	 * currently being processed is returned from this method.
1332
-	 * In case the current execution was not initiated by a web request null is returned
1333
-	 *
1334
-	 * @return \OCP\IRequest
1335
-	 * @deprecated 20.0.0
1336
-	 */
1337
-	public function getRequest() {
1338
-		return $this->get(IRequest::class);
1339
-	}
1340
-
1341
-	/**
1342
-	 * Returns the root folder of ownCloud's data directory
1343
-	 *
1344
-	 * @return IRootFolder
1345
-	 * @deprecated 20.0.0
1346
-	 */
1347
-	public function getRootFolder() {
1348
-		return $this->get(IRootFolder::class);
1349
-	}
1350
-
1351
-	/**
1352
-	 * Returns the root folder of ownCloud's data directory
1353
-	 * This is the lazy variant so this gets only initialized once it
1354
-	 * is actually used.
1355
-	 *
1356
-	 * @return IRootFolder
1357
-	 * @deprecated 20.0.0
1358
-	 */
1359
-	public function getLazyRootFolder() {
1360
-		return $this->get(IRootFolder::class);
1361
-	}
1362
-
1363
-	/**
1364
-	 * Returns a view to ownCloud's files folder
1365
-	 *
1366
-	 * @param string $userId user ID
1367
-	 * @return \OCP\Files\Folder|null
1368
-	 * @deprecated 20.0.0
1369
-	 */
1370
-	public function getUserFolder($userId = null) {
1371
-		if ($userId === null) {
1372
-			$user = $this->get(IUserSession::class)->getUser();
1373
-			if (!$user) {
1374
-				return null;
1375
-			}
1376
-			$userId = $user->getUID();
1377
-		}
1378
-		$root = $this->get(IRootFolder::class);
1379
-		return $root->getUserFolder($userId);
1380
-	}
1381
-
1382
-	/**
1383
-	 * @return \OC\User\Manager
1384
-	 * @deprecated 20.0.0
1385
-	 */
1386
-	public function getUserManager() {
1387
-		return $this->get(IUserManager::class);
1388
-	}
1389
-
1390
-	/**
1391
-	 * @return \OC\Group\Manager
1392
-	 * @deprecated 20.0.0
1393
-	 */
1394
-	public function getGroupManager() {
1395
-		return $this->get(IGroupManager::class);
1396
-	}
1397
-
1398
-	/**
1399
-	 * @return \OC\User\Session
1400
-	 * @deprecated 20.0.0
1401
-	 */
1402
-	public function getUserSession() {
1403
-		return $this->get(IUserSession::class);
1404
-	}
1405
-
1406
-	/**
1407
-	 * @return \OCP\ISession
1408
-	 * @deprecated 20.0.0
1409
-	 */
1410
-	public function getSession() {
1411
-		return $this->get(Session::class)->getSession();
1412
-	}
1413
-
1414
-	/**
1415
-	 * @param \OCP\ISession $session
1416
-	 * @return void
1417
-	 */
1418
-	public function setSession(\OCP\ISession $session) {
1419
-		$this->get(SessionStorage::class)->setSession($session);
1420
-		$this->get(Session::class)->setSession($session);
1421
-		$this->get(Store::class)->setSession($session);
1422
-	}
1423
-
1424
-	/**
1425
-	 * @return \OCP\IConfig
1426
-	 * @deprecated 20.0.0
1427
-	 */
1428
-	public function getConfig() {
1429
-		return $this->get(AllConfig::class);
1430
-	}
1431
-
1432
-	/**
1433
-	 * @return \OC\SystemConfig
1434
-	 * @deprecated 20.0.0
1435
-	 */
1436
-	public function getSystemConfig() {
1437
-		return $this->get(SystemConfig::class);
1438
-	}
1439
-
1440
-	/**
1441
-	 * @return IFactory
1442
-	 * @deprecated 20.0.0
1443
-	 */
1444
-	public function getL10NFactory() {
1445
-		return $this->get(IFactory::class);
1446
-	}
1447
-
1448
-	/**
1449
-	 * get an L10N instance
1450
-	 *
1451
-	 * @param string $app appid
1452
-	 * @param string $lang
1453
-	 * @return IL10N
1454
-	 * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1455
-	 */
1456
-	public function getL10N($app, $lang = null) {
1457
-		return $this->get(IFactory::class)->get($app, $lang);
1458
-	}
1459
-
1460
-	/**
1461
-	 * @return IURLGenerator
1462
-	 * @deprecated 20.0.0
1463
-	 */
1464
-	public function getURLGenerator() {
1465
-		return $this->get(IURLGenerator::class);
1466
-	}
1467
-
1468
-	/**
1469
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1470
-	 * getMemCacheFactory() instead.
1471
-	 *
1472
-	 * @return ICache
1473
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1474
-	 */
1475
-	public function getCache() {
1476
-		return $this->get(ICache::class);
1477
-	}
1478
-
1479
-	/**
1480
-	 * Returns an \OCP\CacheFactory instance
1481
-	 *
1482
-	 * @return \OCP\ICacheFactory
1483
-	 * @deprecated 20.0.0
1484
-	 */
1485
-	public function getMemCacheFactory() {
1486
-		return $this->get(ICacheFactory::class);
1487
-	}
1488
-
1489
-	/**
1490
-	 * Returns the current session
1491
-	 *
1492
-	 * @return \OCP\IDBConnection
1493
-	 * @deprecated 20.0.0
1494
-	 */
1495
-	public function getDatabaseConnection() {
1496
-		return $this->get(IDBConnection::class);
1497
-	}
1498
-
1499
-	/**
1500
-	 * Returns the activity manager
1501
-	 *
1502
-	 * @return \OCP\Activity\IManager
1503
-	 * @deprecated 20.0.0
1504
-	 */
1505
-	public function getActivityManager() {
1506
-		return $this->get(\OCP\Activity\IManager::class);
1507
-	}
1508
-
1509
-	/**
1510
-	 * Returns an job list for controlling background jobs
1511
-	 *
1512
-	 * @return IJobList
1513
-	 * @deprecated 20.0.0
1514
-	 */
1515
-	public function getJobList() {
1516
-		return $this->get(IJobList::class);
1517
-	}
1518
-
1519
-	/**
1520
-	 * Returns a SecureRandom instance
1521
-	 *
1522
-	 * @return \OCP\Security\ISecureRandom
1523
-	 * @deprecated 20.0.0
1524
-	 */
1525
-	public function getSecureRandom() {
1526
-		return $this->get(ISecureRandom::class);
1527
-	}
1528
-
1529
-	/**
1530
-	 * Returns a Crypto instance
1531
-	 *
1532
-	 * @return ICrypto
1533
-	 * @deprecated 20.0.0
1534
-	 */
1535
-	public function getCrypto() {
1536
-		return $this->get(ICrypto::class);
1537
-	}
1538
-
1539
-	/**
1540
-	 * Returns a Hasher instance
1541
-	 *
1542
-	 * @return IHasher
1543
-	 * @deprecated 20.0.0
1544
-	 */
1545
-	public function getHasher() {
1546
-		return $this->get(IHasher::class);
1547
-	}
1548
-
1549
-	/**
1550
-	 * Get the certificate manager
1551
-	 *
1552
-	 * @return \OCP\ICertificateManager
1553
-	 */
1554
-	public function getCertificateManager() {
1555
-		return $this->get(ICertificateManager::class);
1556
-	}
1557
-
1558
-	/**
1559
-	 * Get the manager for temporary files and folders
1560
-	 *
1561
-	 * @return \OCP\ITempManager
1562
-	 * @deprecated 20.0.0
1563
-	 */
1564
-	public function getTempManager() {
1565
-		return $this->get(ITempManager::class);
1566
-	}
1567
-
1568
-	/**
1569
-	 * Get the app manager
1570
-	 *
1571
-	 * @return \OCP\App\IAppManager
1572
-	 * @deprecated 20.0.0
1573
-	 */
1574
-	public function getAppManager() {
1575
-		return $this->get(IAppManager::class);
1576
-	}
1577
-
1578
-	/**
1579
-	 * Creates a new mailer
1580
-	 *
1581
-	 * @return IMailer
1582
-	 * @deprecated 20.0.0
1583
-	 */
1584
-	public function getMailer() {
1585
-		return $this->get(IMailer::class);
1586
-	}
1587
-
1588
-	/**
1589
-	 * Get the webroot
1590
-	 *
1591
-	 * @return string
1592
-	 * @deprecated 20.0.0
1593
-	 */
1594
-	public function getWebRoot() {
1595
-		return $this->webRoot;
1596
-	}
1597
-
1598
-	/**
1599
-	 * Get the locking provider
1600
-	 *
1601
-	 * @return ILockingProvider
1602
-	 * @since 8.1.0
1603
-	 * @deprecated 20.0.0
1604
-	 */
1605
-	public function getLockingProvider() {
1606
-		return $this->get(ILockingProvider::class);
1607
-	}
1608
-
1609
-	/**
1610
-	 * Get the MimeTypeDetector
1611
-	 *
1612
-	 * @return IMimeTypeDetector
1613
-	 * @deprecated 20.0.0
1614
-	 */
1615
-	public function getMimeTypeDetector() {
1616
-		return $this->get(IMimeTypeDetector::class);
1617
-	}
1618
-
1619
-	/**
1620
-	 * Get the MimeTypeLoader
1621
-	 *
1622
-	 * @return IMimeTypeLoader
1623
-	 * @deprecated 20.0.0
1624
-	 */
1625
-	public function getMimeTypeLoader() {
1626
-		return $this->get(IMimeTypeLoader::class);
1627
-	}
1628
-
1629
-	/**
1630
-	 * Get the Notification Manager
1631
-	 *
1632
-	 * @return \OCP\Notification\IManager
1633
-	 * @since 8.2.0
1634
-	 * @deprecated 20.0.0
1635
-	 */
1636
-	public function getNotificationManager() {
1637
-		return $this->get(\OCP\Notification\IManager::class);
1638
-	}
1639
-
1640
-	/**
1641
-	 * @return \OCA\Theming\ThemingDefaults
1642
-	 * @deprecated 20.0.0
1643
-	 */
1644
-	public function getThemingDefaults() {
1645
-		return $this->get('ThemingDefaults');
1646
-	}
1647
-
1648
-	/**
1649
-	 * @return \OC\IntegrityCheck\Checker
1650
-	 * @deprecated 20.0.0
1651
-	 */
1652
-	public function getIntegrityCodeChecker() {
1653
-		return $this->get('IntegrityCodeChecker');
1654
-	}
1655
-
1656
-	/**
1657
-	 * @return CsrfTokenManager
1658
-	 * @deprecated 20.0.0
1659
-	 */
1660
-	public function getCsrfTokenManager() {
1661
-		return $this->get(CsrfTokenManager::class);
1662
-	}
1663
-
1664
-	/**
1665
-	 * @return ContentSecurityPolicyNonceManager
1666
-	 * @deprecated 20.0.0
1667
-	 */
1668
-	public function getContentSecurityPolicyNonceManager() {
1669
-		return $this->get(ContentSecurityPolicyNonceManager::class);
1670
-	}
1671
-
1672
-	/**
1673
-	 * @return \OCP\Settings\IManager
1674
-	 * @deprecated 20.0.0
1675
-	 */
1676
-	public function getSettingsManager() {
1677
-		return $this->get(\OC\Settings\Manager::class);
1678
-	}
1679
-
1680
-	/**
1681
-	 * @return \OCP\Files\IAppData
1682
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1683
-	 */
1684
-	public function getAppDataDir($app) {
1685
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
1686
-		return $factory->get($app);
1687
-	}
1688
-
1689
-	/**
1690
-	 * @return \OCP\Federation\ICloudIdManager
1691
-	 * @deprecated 20.0.0
1692
-	 */
1693
-	public function getCloudIdManager() {
1694
-		return $this->get(ICloudIdManager::class);
1695
-	}
1278
+        $this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1279
+
1280
+        $this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1281
+
1282
+        $this->registerAlias(ISignatureManager::class, SignatureManager::class);
1283
+
1284
+        $this->connectDispatcher();
1285
+    }
1286
+
1287
+    public function boot() {
1288
+        /** @var HookConnector $hookConnector */
1289
+        $hookConnector = $this->get(HookConnector::class);
1290
+        $hookConnector->viewToNode();
1291
+    }
1292
+
1293
+    private function connectDispatcher(): void {
1294
+        /** @var IEventDispatcher $eventDispatcher */
1295
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1296
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1297
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1298
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1299
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1300
+
1301
+        FilesMetadataManager::loadListeners($eventDispatcher);
1302
+        GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1303
+    }
1304
+
1305
+    /**
1306
+     * @return \OCP\Contacts\IManager
1307
+     * @deprecated 20.0.0
1308
+     */
1309
+    public function getContactsManager() {
1310
+        return $this->get(\OCP\Contacts\IManager::class);
1311
+    }
1312
+
1313
+    /**
1314
+     * @return \OC\Encryption\Manager
1315
+     * @deprecated 20.0.0
1316
+     */
1317
+    public function getEncryptionManager() {
1318
+        return $this->get(\OCP\Encryption\IManager::class);
1319
+    }
1320
+
1321
+    /**
1322
+     * @return \OC\Encryption\File
1323
+     * @deprecated 20.0.0
1324
+     */
1325
+    public function getEncryptionFilesHelper() {
1326
+        return $this->get(IFile::class);
1327
+    }
1328
+
1329
+    /**
1330
+     * The current request object holding all information about the request
1331
+     * currently being processed is returned from this method.
1332
+     * In case the current execution was not initiated by a web request null is returned
1333
+     *
1334
+     * @return \OCP\IRequest
1335
+     * @deprecated 20.0.0
1336
+     */
1337
+    public function getRequest() {
1338
+        return $this->get(IRequest::class);
1339
+    }
1340
+
1341
+    /**
1342
+     * Returns the root folder of ownCloud's data directory
1343
+     *
1344
+     * @return IRootFolder
1345
+     * @deprecated 20.0.0
1346
+     */
1347
+    public function getRootFolder() {
1348
+        return $this->get(IRootFolder::class);
1349
+    }
1350
+
1351
+    /**
1352
+     * Returns the root folder of ownCloud's data directory
1353
+     * This is the lazy variant so this gets only initialized once it
1354
+     * is actually used.
1355
+     *
1356
+     * @return IRootFolder
1357
+     * @deprecated 20.0.0
1358
+     */
1359
+    public function getLazyRootFolder() {
1360
+        return $this->get(IRootFolder::class);
1361
+    }
1362
+
1363
+    /**
1364
+     * Returns a view to ownCloud's files folder
1365
+     *
1366
+     * @param string $userId user ID
1367
+     * @return \OCP\Files\Folder|null
1368
+     * @deprecated 20.0.0
1369
+     */
1370
+    public function getUserFolder($userId = null) {
1371
+        if ($userId === null) {
1372
+            $user = $this->get(IUserSession::class)->getUser();
1373
+            if (!$user) {
1374
+                return null;
1375
+            }
1376
+            $userId = $user->getUID();
1377
+        }
1378
+        $root = $this->get(IRootFolder::class);
1379
+        return $root->getUserFolder($userId);
1380
+    }
1381
+
1382
+    /**
1383
+     * @return \OC\User\Manager
1384
+     * @deprecated 20.0.0
1385
+     */
1386
+    public function getUserManager() {
1387
+        return $this->get(IUserManager::class);
1388
+    }
1389
+
1390
+    /**
1391
+     * @return \OC\Group\Manager
1392
+     * @deprecated 20.0.0
1393
+     */
1394
+    public function getGroupManager() {
1395
+        return $this->get(IGroupManager::class);
1396
+    }
1397
+
1398
+    /**
1399
+     * @return \OC\User\Session
1400
+     * @deprecated 20.0.0
1401
+     */
1402
+    public function getUserSession() {
1403
+        return $this->get(IUserSession::class);
1404
+    }
1405
+
1406
+    /**
1407
+     * @return \OCP\ISession
1408
+     * @deprecated 20.0.0
1409
+     */
1410
+    public function getSession() {
1411
+        return $this->get(Session::class)->getSession();
1412
+    }
1413
+
1414
+    /**
1415
+     * @param \OCP\ISession $session
1416
+     * @return void
1417
+     */
1418
+    public function setSession(\OCP\ISession $session) {
1419
+        $this->get(SessionStorage::class)->setSession($session);
1420
+        $this->get(Session::class)->setSession($session);
1421
+        $this->get(Store::class)->setSession($session);
1422
+    }
1423
+
1424
+    /**
1425
+     * @return \OCP\IConfig
1426
+     * @deprecated 20.0.0
1427
+     */
1428
+    public function getConfig() {
1429
+        return $this->get(AllConfig::class);
1430
+    }
1431
+
1432
+    /**
1433
+     * @return \OC\SystemConfig
1434
+     * @deprecated 20.0.0
1435
+     */
1436
+    public function getSystemConfig() {
1437
+        return $this->get(SystemConfig::class);
1438
+    }
1439
+
1440
+    /**
1441
+     * @return IFactory
1442
+     * @deprecated 20.0.0
1443
+     */
1444
+    public function getL10NFactory() {
1445
+        return $this->get(IFactory::class);
1446
+    }
1447
+
1448
+    /**
1449
+     * get an L10N instance
1450
+     *
1451
+     * @param string $app appid
1452
+     * @param string $lang
1453
+     * @return IL10N
1454
+     * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1455
+     */
1456
+    public function getL10N($app, $lang = null) {
1457
+        return $this->get(IFactory::class)->get($app, $lang);
1458
+    }
1459
+
1460
+    /**
1461
+     * @return IURLGenerator
1462
+     * @deprecated 20.0.0
1463
+     */
1464
+    public function getURLGenerator() {
1465
+        return $this->get(IURLGenerator::class);
1466
+    }
1467
+
1468
+    /**
1469
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1470
+     * getMemCacheFactory() instead.
1471
+     *
1472
+     * @return ICache
1473
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1474
+     */
1475
+    public function getCache() {
1476
+        return $this->get(ICache::class);
1477
+    }
1478
+
1479
+    /**
1480
+     * Returns an \OCP\CacheFactory instance
1481
+     *
1482
+     * @return \OCP\ICacheFactory
1483
+     * @deprecated 20.0.0
1484
+     */
1485
+    public function getMemCacheFactory() {
1486
+        return $this->get(ICacheFactory::class);
1487
+    }
1488
+
1489
+    /**
1490
+     * Returns the current session
1491
+     *
1492
+     * @return \OCP\IDBConnection
1493
+     * @deprecated 20.0.0
1494
+     */
1495
+    public function getDatabaseConnection() {
1496
+        return $this->get(IDBConnection::class);
1497
+    }
1498
+
1499
+    /**
1500
+     * Returns the activity manager
1501
+     *
1502
+     * @return \OCP\Activity\IManager
1503
+     * @deprecated 20.0.0
1504
+     */
1505
+    public function getActivityManager() {
1506
+        return $this->get(\OCP\Activity\IManager::class);
1507
+    }
1508
+
1509
+    /**
1510
+     * Returns an job list for controlling background jobs
1511
+     *
1512
+     * @return IJobList
1513
+     * @deprecated 20.0.0
1514
+     */
1515
+    public function getJobList() {
1516
+        return $this->get(IJobList::class);
1517
+    }
1518
+
1519
+    /**
1520
+     * Returns a SecureRandom instance
1521
+     *
1522
+     * @return \OCP\Security\ISecureRandom
1523
+     * @deprecated 20.0.0
1524
+     */
1525
+    public function getSecureRandom() {
1526
+        return $this->get(ISecureRandom::class);
1527
+    }
1528
+
1529
+    /**
1530
+     * Returns a Crypto instance
1531
+     *
1532
+     * @return ICrypto
1533
+     * @deprecated 20.0.0
1534
+     */
1535
+    public function getCrypto() {
1536
+        return $this->get(ICrypto::class);
1537
+    }
1538
+
1539
+    /**
1540
+     * Returns a Hasher instance
1541
+     *
1542
+     * @return IHasher
1543
+     * @deprecated 20.0.0
1544
+     */
1545
+    public function getHasher() {
1546
+        return $this->get(IHasher::class);
1547
+    }
1548
+
1549
+    /**
1550
+     * Get the certificate manager
1551
+     *
1552
+     * @return \OCP\ICertificateManager
1553
+     */
1554
+    public function getCertificateManager() {
1555
+        return $this->get(ICertificateManager::class);
1556
+    }
1557
+
1558
+    /**
1559
+     * Get the manager for temporary files and folders
1560
+     *
1561
+     * @return \OCP\ITempManager
1562
+     * @deprecated 20.0.0
1563
+     */
1564
+    public function getTempManager() {
1565
+        return $this->get(ITempManager::class);
1566
+    }
1567
+
1568
+    /**
1569
+     * Get the app manager
1570
+     *
1571
+     * @return \OCP\App\IAppManager
1572
+     * @deprecated 20.0.0
1573
+     */
1574
+    public function getAppManager() {
1575
+        return $this->get(IAppManager::class);
1576
+    }
1577
+
1578
+    /**
1579
+     * Creates a new mailer
1580
+     *
1581
+     * @return IMailer
1582
+     * @deprecated 20.0.0
1583
+     */
1584
+    public function getMailer() {
1585
+        return $this->get(IMailer::class);
1586
+    }
1587
+
1588
+    /**
1589
+     * Get the webroot
1590
+     *
1591
+     * @return string
1592
+     * @deprecated 20.0.0
1593
+     */
1594
+    public function getWebRoot() {
1595
+        return $this->webRoot;
1596
+    }
1597
+
1598
+    /**
1599
+     * Get the locking provider
1600
+     *
1601
+     * @return ILockingProvider
1602
+     * @since 8.1.0
1603
+     * @deprecated 20.0.0
1604
+     */
1605
+    public function getLockingProvider() {
1606
+        return $this->get(ILockingProvider::class);
1607
+    }
1608
+
1609
+    /**
1610
+     * Get the MimeTypeDetector
1611
+     *
1612
+     * @return IMimeTypeDetector
1613
+     * @deprecated 20.0.0
1614
+     */
1615
+    public function getMimeTypeDetector() {
1616
+        return $this->get(IMimeTypeDetector::class);
1617
+    }
1618
+
1619
+    /**
1620
+     * Get the MimeTypeLoader
1621
+     *
1622
+     * @return IMimeTypeLoader
1623
+     * @deprecated 20.0.0
1624
+     */
1625
+    public function getMimeTypeLoader() {
1626
+        return $this->get(IMimeTypeLoader::class);
1627
+    }
1628
+
1629
+    /**
1630
+     * Get the Notification Manager
1631
+     *
1632
+     * @return \OCP\Notification\IManager
1633
+     * @since 8.2.0
1634
+     * @deprecated 20.0.0
1635
+     */
1636
+    public function getNotificationManager() {
1637
+        return $this->get(\OCP\Notification\IManager::class);
1638
+    }
1639
+
1640
+    /**
1641
+     * @return \OCA\Theming\ThemingDefaults
1642
+     * @deprecated 20.0.0
1643
+     */
1644
+    public function getThemingDefaults() {
1645
+        return $this->get('ThemingDefaults');
1646
+    }
1647
+
1648
+    /**
1649
+     * @return \OC\IntegrityCheck\Checker
1650
+     * @deprecated 20.0.0
1651
+     */
1652
+    public function getIntegrityCodeChecker() {
1653
+        return $this->get('IntegrityCodeChecker');
1654
+    }
1655
+
1656
+    /**
1657
+     * @return CsrfTokenManager
1658
+     * @deprecated 20.0.0
1659
+     */
1660
+    public function getCsrfTokenManager() {
1661
+        return $this->get(CsrfTokenManager::class);
1662
+    }
1663
+
1664
+    /**
1665
+     * @return ContentSecurityPolicyNonceManager
1666
+     * @deprecated 20.0.0
1667
+     */
1668
+    public function getContentSecurityPolicyNonceManager() {
1669
+        return $this->get(ContentSecurityPolicyNonceManager::class);
1670
+    }
1671
+
1672
+    /**
1673
+     * @return \OCP\Settings\IManager
1674
+     * @deprecated 20.0.0
1675
+     */
1676
+    public function getSettingsManager() {
1677
+        return $this->get(\OC\Settings\Manager::class);
1678
+    }
1679
+
1680
+    /**
1681
+     * @return \OCP\Files\IAppData
1682
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1683
+     */
1684
+    public function getAppDataDir($app) {
1685
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
1686
+        return $factory->get($app);
1687
+    }
1688
+
1689
+    /**
1690
+     * @return \OCP\Federation\ICloudIdManager
1691
+     * @deprecated 20.0.0
1692
+     */
1693
+    public function getCloudIdManager() {
1694
+        return $this->get(ICloudIdManager::class);
1695
+    }
1696 1696
 }
Please login to merge, or discard this patch.
lib/private/ContextChat/ContentManager.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -13,44 +13,44 @@
 block discarded – undo
13 13
 use OCP\ContextChat\IContentManager;
14 14
 
15 15
 class ContentManager implements IContentManager {
16
-	public function __construct(
17
-		private ?ContextChatContentManager $contentManager,
18
-	) {
19
-	}
20
-
21
-	public function isContextChatAvailable(): bool {
22
-		return $this->contentManager !== null;
23
-	}
24
-
25
-	public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
26
-		$this->contentManager?->registerContentProvider($appId, $providerId, $providerClass);
27
-	}
28
-
29
-	public function collectAllContentProviders(): void {
30
-		$this->contentManager?->collectAllContentProviders();
31
-	}
32
-
33
-	public function submitContent(string $appId, array $items): void {
34
-		$this->contentManager?->submitContent($appId, $items);
35
-	}
36
-
37
-	public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void {
38
-		$this->contentManager?->updateAccess($appId, $providerId, $itemId, $op, $userIds);
39
-	}
40
-
41
-	public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void {
42
-		$this->contentManager?->updateAccessProvider($appId, $providerId, $op, $userIds);
43
-	}
44
-
45
-	public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void {
46
-		$this->contentManager?->updateAccessDeclarative($appId, $providerId, $itemId, $op, $userIds);
47
-	}
48
-
49
-	public function deleteProvider(string $appId, string $providerId): void {
50
-		$this->contentManager?->deleteProvider($appId, $providerId);
51
-	}
52
-
53
-	public function deleteContent(string $appId, string $providerId, array $itemIds): void {
54
-		$this->contentManager?->deleteContent($appId, $providerId, $itemIds);
55
-	}
16
+    public function __construct(
17
+        private ?ContextChatContentManager $contentManager,
18
+    ) {
19
+    }
20
+
21
+    public function isContextChatAvailable(): bool {
22
+        return $this->contentManager !== null;
23
+    }
24
+
25
+    public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
26
+        $this->contentManager?->registerContentProvider($appId, $providerId, $providerClass);
27
+    }
28
+
29
+    public function collectAllContentProviders(): void {
30
+        $this->contentManager?->collectAllContentProviders();
31
+    }
32
+
33
+    public function submitContent(string $appId, array $items): void {
34
+        $this->contentManager?->submitContent($appId, $items);
35
+    }
36
+
37
+    public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void {
38
+        $this->contentManager?->updateAccess($appId, $providerId, $itemId, $op, $userIds);
39
+    }
40
+
41
+    public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void {
42
+        $this->contentManager?->updateAccessProvider($appId, $providerId, $op, $userIds);
43
+    }
44
+
45
+    public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void {
46
+        $this->contentManager?->updateAccessDeclarative($appId, $providerId, $itemId, $op, $userIds);
47
+    }
48
+
49
+    public function deleteProvider(string $appId, string $providerId): void {
50
+        $this->contentManager?->deleteProvider($appId, $providerId);
51
+    }
52
+
53
+    public function deleteContent(string $appId, string $providerId, array $itemIds): void {
54
+        $this->contentManager?->deleteContent($appId, $providerId, $itemIds);
55
+    }
56 56
 }
Please login to merge, or discard this patch.
lib/public/ContextChat/Type/UpdateAccessOp.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
  * @since 32.0.0
14 14
  */
15 15
 class UpdateAccessOp {
16
-	public const ALLOW = 'allow';
17
-	public const DENY = 'deny';
16
+    public const ALLOW = 'allow';
17
+    public const DENY = 'deny';
18 18
 }
Please login to merge, or discard this patch.
lib/public/ContextChat/IContentProvider.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,36 +14,36 @@
 block discarded – undo
14 14
  * @since 32.0.0
15 15
  */
16 16
 interface IContentProvider {
17
-	/**
18
-	 * The ID of the provider
19
-	 *
20
-	 * @return string
21
-	 * @since 32.0.0
22
-	 */
23
-	public function getId(): string;
17
+    /**
18
+     * The ID of the provider
19
+     *
20
+     * @return string
21
+     * @since 32.0.0
22
+     */
23
+    public function getId(): string;
24 24
 
25
-	/**
26
-	 * The ID of the app making the provider avaialble
27
-	 *
28
-	 * @return string
29
-	 * @since 32.0.0
30
-	 */
31
-	public function getAppId(): string;
25
+    /**
26
+     * The ID of the app making the provider avaialble
27
+     *
28
+     * @return string
29
+     * @since 32.0.0
30
+     */
31
+    public function getAppId(): string;
32 32
 
33
-	/**
34
-	 * The absolute URL to the content item
35
-	 *
36
-	 * @param string $id
37
-	 * @return string
38
-	 * @since 32.0.0
39
-	 */
40
-	public function getItemUrl(string $id): string;
33
+    /**
34
+     * The absolute URL to the content item
35
+     *
36
+     * @param string $id
37
+     * @return string
38
+     * @since 32.0.0
39
+     */
40
+    public function getItemUrl(string $id): string;
41 41
 
42
-	/**
43
-	 * Starts the initial import of content items into context chat
44
-	 *
45
-	 * @return void
46
-	 * @since 32.0.0
47
-	 */
48
-	public function triggerInitialImport(): void;
42
+    /**
43
+     * Starts the initial import of content items into context chat
44
+     *
45
+     * @return void
46
+     * @since 32.0.0
47
+     */
48
+    public function triggerInitialImport(): void;
49 49
 }
Please login to merge, or discard this patch.
lib/public/ContextChat/Events/ContentProviderRegisterEvent.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@
 block discarded – undo
17 17
  * @since 32.0.0
18 18
  */
19 19
 class ContentProviderRegisterEvent extends Event {
20
-	public function __construct(
21
-		private IContentManager $contentManager,
22
-	) {
23
-	}
20
+    public function __construct(
21
+        private IContentManager $contentManager,
22
+    ) {
23
+    }
24 24
 
25
-	/**
26
-	 * @param string $appId
27
-	 * @param string $providerId
28
-	 * @param class-string<IContentProvider> $providerClass
29
-	 * @return void
30
-	 * @since 32.0.0
31
-	 */
32
-	public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
33
-		$this->contentManager->registerContentProvider($appId, $providerId, $providerClass);
34
-	}
25
+    /**
26
+     * @param string $appId
27
+     * @param string $providerId
28
+     * @param class-string<IContentProvider> $providerClass
29
+     * @return void
30
+     * @since 32.0.0
31
+     */
32
+    public function registerContentProvider(string $appId, string $providerId, string $providerClass): void {
33
+        $this->contentManager->registerContentProvider($appId, $providerId, $providerClass);
34
+    }
35 35
 }
Please login to merge, or discard this patch.
lib/public/ContextChat/IContentManager.php 1 patch
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -13,103 +13,103 @@
 block discarded – undo
13 13
  * @since 32.0.0
14 14
  */
15 15
 interface IContentManager {
16
-	/**
17
-	 * Checks if the context chat app is enabled or not
18
-	 *
19
-	 * @return bool
20
-	 * @since 32.0.0
21
-	 */
22
-	public function isContextChatAvailable(): bool;
16
+    /**
17
+     * Checks if the context chat app is enabled or not
18
+     *
19
+     * @return bool
20
+     * @since 32.0.0
21
+     */
22
+    public function isContextChatAvailable(): bool;
23 23
 
24
-	/**
25
-	 * @param string $appId
26
-	 * @param string $providerId
27
-	 * @param class-string<IContentProvider> $providerClass
28
-	 * @return void
29
-	 * @since 32.0.0
30
-	 */
31
-	public function registerContentProvider(string $appId, string $providerId, string $providerClass): void;
24
+    /**
25
+     * @param string $appId
26
+     * @param string $providerId
27
+     * @param class-string<IContentProvider> $providerClass
28
+     * @return void
29
+     * @since 32.0.0
30
+     */
31
+    public function registerContentProvider(string $appId, string $providerId, string $providerClass): void;
32 32
 
33
-	/**
34
-	 * Emits an event to collect all content providers
35
-	 *
36
-	 * @return void
37
-	 * @since 32.0.0
38
-	 */
39
-	public function collectAllContentProviders(): void;
33
+    /**
34
+     * Emits an event to collect all content providers
35
+     *
36
+     * @return void
37
+     * @since 32.0.0
38
+     */
39
+    public function collectAllContentProviders(): void;
40 40
 
41
-	/**
42
-	 * Providers can use this to submit content for indexing in context chat
43
-	 *
44
-	 * @param string $appId
45
-	 * @param ContentItem[] $items
46
-	 * @return void
47
-	 * @since 32.0.0
48
-	 */
49
-	public function submitContent(string $appId, array $items): void;
41
+    /**
42
+     * Providers can use this to submit content for indexing in context chat
43
+     *
44
+     * @param string $appId
45
+     * @param ContentItem[] $items
46
+     * @return void
47
+     * @since 32.0.0
48
+     */
49
+    public function submitContent(string $appId, array $items): void;
50 50
 
51
-	/**
52
-	 * Update access for a content item for specified users.
53
-	 * This modifies the access list for the content item,
54
-	 * 	allowing or denying access to the specified users.
55
-	 * If no user has access to the content item, it will be removed from the knowledge base.
56
-	 *
57
-	 * @param string $appId
58
-	 * @param string $providerId
59
-	 * @param string $itemId
60
-	 * @param Type\UpdateAccessOp::* $op
61
-	 * @param array $userIds
62
-	 * @return void
63
-	 * @since 32.0.0
64
-	 */
65
-	public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void;
51
+    /**
52
+     * Update access for a content item for specified users.
53
+     * This modifies the access list for the content item,
54
+     * 	allowing or denying access to the specified users.
55
+     * If no user has access to the content item, it will be removed from the knowledge base.
56
+     *
57
+     * @param string $appId
58
+     * @param string $providerId
59
+     * @param string $itemId
60
+     * @param Type\UpdateAccessOp::* $op
61
+     * @param array $userIds
62
+     * @return void
63
+     * @since 32.0.0
64
+     */
65
+    public function updateAccess(string $appId, string $providerId, string $itemId, string $op, array $userIds): void;
66 66
 
67
-	/**
68
-	 * Update access for content items from the given provider for specified users.
69
-	 * If no user has access to the content item, it will be removed from the knowledge base.
70
-	 *
71
-	 * @param string $appId
72
-	 * @param string $providerId
73
-	 * @param Type\UpdateAccessOp::* $op
74
-	 * @param array $userIds
75
-	 * @return void
76
-	 * @since 32.0.0
77
-	 */
78
-	public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void;
67
+    /**
68
+     * Update access for content items from the given provider for specified users.
69
+     * If no user has access to the content item, it will be removed from the knowledge base.
70
+     *
71
+     * @param string $appId
72
+     * @param string $providerId
73
+     * @param Type\UpdateAccessOp::* $op
74
+     * @param array $userIds
75
+     * @return void
76
+     * @since 32.0.0
77
+     */
78
+    public function updateAccessProvider(string $appId, string $providerId, string $op, array $userIds): void;
79 79
 
80
-	/**
81
-	 * Update access for a content item for specified users declaratively.
82
-	 * This overwrites the access list for the content item,
83
-	 * 	allowing only the specified users access to it.
84
-	 *
85
-	 * @param string $appId
86
-	 * @param string $providerId
87
-	 * @param string $itemId
88
-	 * @param array $userIds
89
-	 * @return void
90
-	 * @since 32.0.0
91
-	 */
92
-	public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void;
80
+    /**
81
+     * Update access for a content item for specified users declaratively.
82
+     * This overwrites the access list for the content item,
83
+     * 	allowing only the specified users access to it.
84
+     *
85
+     * @param string $appId
86
+     * @param string $providerId
87
+     * @param string $itemId
88
+     * @param array $userIds
89
+     * @return void
90
+     * @since 32.0.0
91
+     */
92
+    public function updateAccessDeclarative(string $appId, string $providerId, string $itemId, array $userIds): void;
93 93
 
94
-	/**
95
-	 * Delete all content items and access lists for a provider.
96
-	 * This does not unregister the provider itself.
97
-	 *
98
-	 * @param string $appId
99
-	 * @param string $providerId
100
-	 * @return void
101
-	 * @since 32.0.0
102
-	 */
103
-	public function deleteProvider(string $appId, string $providerId): void;
94
+    /**
95
+     * Delete all content items and access lists for a provider.
96
+     * This does not unregister the provider itself.
97
+     *
98
+     * @param string $appId
99
+     * @param string $providerId
100
+     * @return void
101
+     * @since 32.0.0
102
+     */
103
+    public function deleteProvider(string $appId, string $providerId): void;
104 104
 
105
-	/**
106
-	 * Remove a content item from the knowledge base of context chat.
107
-	 *
108
-	 * @param string $appId
109
-	 * @param string $providerId
110
-	 * @param string[] $itemIds
111
-	 * @return void
112
-	 * @since 32.0.0
113
-	 */
114
-	public function deleteContent(string $appId, string $providerId, array $itemIds): void;
105
+    /**
106
+     * Remove a content item from the knowledge base of context chat.
107
+     *
108
+     * @param string $appId
109
+     * @param string $providerId
110
+     * @param string[] $itemIds
111
+     * @return void
112
+     * @since 32.0.0
113
+     */
114
+    public function deleteContent(string $appId, string $providerId, array $itemIds): void;
115 115
 }
Please login to merge, or discard this patch.
lib/public/ContextChat/ContentItem.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@
 block discarded – undo
13 13
  * @since 32.0.0
14 14
  */
15 15
 class ContentItem {
16
-	/**
17
-	 * @param string $itemId
18
-	 * @param string $providerId
19
-	 * @param string $title
20
-	 * @param string $content
21
-	 * @param string $documentType
22
-	 * @param \DateTime $lastModified
23
-	 * @param string[] $users
24
-	 * @since 32.0.0
25
-	 */
26
-	public function __construct(
27
-		/**
28
-		 * @since 32.0.0
29
-		 */
30
-		public string $itemId,
31
-		/**
32
-		 * @since 32.0.0
33
-		 */
34
-		public string $providerId,
35
-		/**
36
-		 * @since 32.0.0
37
-		 */
38
-		public string $title,
39
-		/**
40
-		 * @since 32.0.0
41
-		 */
42
-		public string $content,
43
-		/**
44
-		 * @since 32.0.0
45
-		 */
46
-		public string $documentType,
47
-		/**
48
-		 * @since 32.0.0
49
-		 */
50
-		public \DateTime $lastModified,
51
-		/**
52
-		 * @since 32.0.0
53
-		 */
54
-		public array $users,
55
-	) {
56
-	}
16
+    /**
17
+     * @param string $itemId
18
+     * @param string $providerId
19
+     * @param string $title
20
+     * @param string $content
21
+     * @param string $documentType
22
+     * @param \DateTime $lastModified
23
+     * @param string[] $users
24
+     * @since 32.0.0
25
+     */
26
+    public function __construct(
27
+        /**
28
+         * @since 32.0.0
29
+         */
30
+        public string $itemId,
31
+        /**
32
+         * @since 32.0.0
33
+         */
34
+        public string $providerId,
35
+        /**
36
+         * @since 32.0.0
37
+         */
38
+        public string $title,
39
+        /**
40
+         * @since 32.0.0
41
+         */
42
+        public string $content,
43
+        /**
44
+         * @since 32.0.0
45
+         */
46
+        public string $documentType,
47
+        /**
48
+         * @since 32.0.0
49
+         */
50
+        public \DateTime $lastModified,
51
+        /**
52
+         * @since 32.0.0
53
+         */
54
+        public array $users,
55
+    ) {
56
+    }
57 57
 }
Please login to merge, or discard this patch.