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