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