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