Completed
Push — master ( 0bb1de...4a63bd )
by
unknown
20:13
created
lib/private/Server.php 1 patch
Indentation   +1379 added lines, -1379 removed lines patch added patch discarded remove patch
@@ -255,1425 +255,1425 @@
 block discarded – undo
255 255
  * TODO: hookup all manager classes
256 256
  */
257 257
 class Server extends ServerContainer implements IServerContainer {
258
-	/** @var string */
259
-	private $webRoot;
260
-
261
-	/**
262
-	 * @param string $webRoot
263
-	 * @param \OC\Config $config
264
-	 */
265
-	public function __construct($webRoot, \OC\Config $config) {
266
-		parent::__construct();
267
-		$this->webRoot = $webRoot;
268
-
269
-		// To find out if we are running from CLI or not
270
-		$this->registerParameter('isCLI', \OC::$CLI);
271
-		$this->registerParameter('serverRoot', \OC::$SERVERROOT);
272
-
273
-		$this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
274
-			return $c;
275
-		});
276
-		$this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
277
-
278
-		$this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
279
-
280
-		$this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
281
-
282
-		$this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
283
-
284
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
285
-
286
-		$this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
287
-
288
-		$this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
289
-		$this->registerAlias(ITemplateManager::class, TemplateManager::class);
290
-		$this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
291
-
292
-		$this->registerAlias(IActionFactory::class, ActionFactory::class);
293
-
294
-		$this->registerService(View::class, function (Server $c) {
295
-			return new View();
296
-		}, false);
297
-
298
-		$this->registerService(IPreview::class, function (ContainerInterface $c) {
299
-			return new PreviewManager(
300
-				$c->get(\OCP\IConfig::class),
301
-				$c->get(IRootFolder::class),
302
-				$c->get(IEventDispatcher::class),
303
-				$c->get(GeneratorHelper::class),
304
-				$c->get(ISession::class)->get('user_id'),
305
-				$c->get(Coordinator::class),
306
-				$c->get(IServerContainer::class),
307
-				$c->get(IBinaryFinder::class),
308
-				$c->get(IMagickSupport::class)
309
-			);
310
-		});
311
-		$this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
312
-
313
-		$this->registerService(Watcher::class, function (ContainerInterface $c): Watcher {
314
-			return new Watcher(
315
-				$c->get(\OC\Preview\Storage\StorageFactory::class),
316
-				$c->get(PreviewMapper::class),
317
-				$c->get(IDBConnection::class),
318
-			);
319
-		});
320
-
321
-		$this->registerService(IProfiler::class, function (Server $c) {
322
-			return new Profiler($c->get(SystemConfig::class));
323
-		});
324
-
325
-		$this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
326
-			$view = new View();
327
-			$util = new Encryption\Util(
328
-				$view,
329
-				$c->get(IUserManager::class),
330
-				$c->get(IGroupManager::class),
331
-				$c->get(\OCP\IConfig::class)
332
-			);
333
-			return new Encryption\Manager(
334
-				$c->get(\OCP\IConfig::class),
335
-				$c->get(LoggerInterface::class),
336
-				$c->getL10N('core'),
337
-				new View(),
338
-				$util,
339
-				new ArrayCache()
340
-			);
341
-		});
342
-		$this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
343
-
344
-		$this->registerService(IFile::class, function (ContainerInterface $c) {
345
-			$util = new Encryption\Util(
346
-				new View(),
347
-				$c->get(IUserManager::class),
348
-				$c->get(IGroupManager::class),
349
-				$c->get(\OCP\IConfig::class)
350
-			);
351
-			return new Encryption\File(
352
-				$util,
353
-				$c->get(IRootFolder::class),
354
-				$c->get(\OCP\Share\IManager::class)
355
-			);
356
-		});
357
-
358
-		$this->registerService(IStorage::class, function (ContainerInterface $c) {
359
-			$view = new View();
360
-			$util = new Encryption\Util(
361
-				$view,
362
-				$c->get(IUserManager::class),
363
-				$c->get(IGroupManager::class),
364
-				$c->get(\OCP\IConfig::class)
365
-			);
366
-
367
-			return new Encryption\Keys\Storage(
368
-				$view,
369
-				$util,
370
-				$c->get(ICrypto::class),
371
-				$c->get(\OCP\IConfig::class)
372
-			);
373
-		});
374
-
375
-		$this->registerAlias(\OCP\ITagManager::class, TagManager::class);
376
-
377
-		$this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
378
-			/** @var \OCP\IConfig $config */
379
-			$config = $c->get(\OCP\IConfig::class);
380
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
381
-			return new $factoryClass($this);
382
-		});
383
-		$this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
384
-			return $c->get('SystemTagManagerFactory')->getManager();
385
-		});
386
-		/** @deprecated 19.0.0 */
387
-		$this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
388
-
389
-		$this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
390
-			return $c->get('SystemTagManagerFactory')->getObjectMapper();
391
-		});
392
-		$this->registerAlias(IFileAccess::class, FileAccess::class);
393
-		$this->registerService('RootFolder', function (ContainerInterface $c) {
394
-			$manager = \OC\Files\Filesystem::getMountManager();
395
-			$view = new View();
396
-			/** @var IUserSession $userSession */
397
-			$userSession = $c->get(IUserSession::class);
398
-			$root = new Root(
399
-				$manager,
400
-				$view,
401
-				$userSession->getUser(),
402
-				$c->get(IUserMountCache::class),
403
-				$this->get(LoggerInterface::class),
404
-				$this->get(IUserManager::class),
405
-				$this->get(IEventDispatcher::class),
406
-				$this->get(ICacheFactory::class),
407
-				$this->get(IAppConfig::class),
408
-			);
409
-
410
-			$previewConnector = new \OC\Preview\WatcherConnector(
411
-				$root,
412
-				$c->get(SystemConfig::class),
413
-				$this->get(IEventDispatcher::class)
414
-			);
415
-			$previewConnector->connectWatcher();
416
-
417
-			return $root;
418
-		});
419
-		$this->registerService(HookConnector::class, function (ContainerInterface $c) {
420
-			return new HookConnector(
421
-				$c->get(IRootFolder::class),
422
-				new View(),
423
-				$c->get(IEventDispatcher::class),
424
-				$c->get(LoggerInterface::class)
425
-			);
426
-		});
427
-
428
-		$this->registerService(IRootFolder::class, function (ContainerInterface $c) {
429
-			return new LazyRoot(function () use ($c) {
430
-				return $c->get('RootFolder');
431
-			});
432
-		});
433
-
434
-		$this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
435
-
436
-		$this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
437
-			return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
438
-		});
439
-
440
-		$this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
441
-			$groupManager = new \OC\Group\Manager(
442
-				$this->get(IUserManager::class),
443
-				$this->get(IEventDispatcher::class),
444
-				$this->get(LoggerInterface::class),
445
-				$this->get(ICacheFactory::class),
446
-				$this->get(IRemoteAddress::class),
447
-			);
448
-			return $groupManager;
449
-		});
450
-
451
-		$this->registerService(Store::class, function (ContainerInterface $c) {
452
-			$session = $c->get(ISession::class);
453
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
454
-				$tokenProvider = $c->get(IProvider::class);
455
-			} else {
456
-				$tokenProvider = null;
457
-			}
458
-			$logger = $c->get(LoggerInterface::class);
459
-			$crypto = $c->get(ICrypto::class);
460
-			return new Store($session, $logger, $crypto, $tokenProvider);
461
-		});
462
-		$this->registerAlias(IStore::class, Store::class);
463
-		$this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
464
-		$this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
465
-
466
-		$this->registerService(\OC\User\Session::class, function (Server $c) {
467
-			$manager = $c->get(IUserManager::class);
468
-			$session = new \OC\Session\Memory();
469
-			$timeFactory = new TimeFactory();
470
-			// Token providers might require a working database. This code
471
-			// might however be called when Nextcloud is not yet setup.
472
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
473
-				$provider = $c->get(IProvider::class);
474
-			} else {
475
-				$provider = null;
476
-			}
477
-
478
-			$userSession = new \OC\User\Session(
479
-				$manager,
480
-				$session,
481
-				$timeFactory,
482
-				$provider,
483
-				$c->get(\OCP\IConfig::class),
484
-				$c->get(ISecureRandom::class),
485
-				$c->get('LockdownManager'),
486
-				$c->get(LoggerInterface::class),
487
-				$c->get(IEventDispatcher::class),
488
-			);
489
-			/** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
490
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
491
-				\OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
492
-			});
493
-			/** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
494
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
495
-				/** @var \OC\User\User $user */
496
-				\OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
497
-			});
498
-			/** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
499
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
500
-				/** @var \OC\User\User $user */
501
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
502
-			});
503
-			/** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
504
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
505
-				/** @var \OC\User\User $user */
506
-				\OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
507
-			});
508
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
509
-				/** @var \OC\User\User $user */
510
-				\OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
511
-			});
512
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
513
-				/** @var \OC\User\User $user */
514
-				\OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
515
-			});
516
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
517
-				\OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
518
-
519
-				/** @var IEventDispatcher $dispatcher */
520
-				$dispatcher = $this->get(IEventDispatcher::class);
521
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
522
-			});
523
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
524
-				/** @var \OC\User\User $user */
525
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
526
-
527
-				/** @var IEventDispatcher $dispatcher */
528
-				$dispatcher = $this->get(IEventDispatcher::class);
529
-				$dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
530
-			});
531
-			$userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
532
-				/** @var IEventDispatcher $dispatcher */
533
-				$dispatcher = $this->get(IEventDispatcher::class);
534
-				$dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
535
-			});
536
-			$userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
537
-				/** @var \OC\User\User $user */
538
-				\OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
539
-
540
-				/** @var IEventDispatcher $dispatcher */
541
-				$dispatcher = $this->get(IEventDispatcher::class);
542
-				$dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
543
-			});
544
-			$userSession->listen('\OC\User', 'logout', function ($user) {
545
-				\OC_Hook::emit('OC_User', 'logout', []);
546
-
547
-				/** @var IEventDispatcher $dispatcher */
548
-				$dispatcher = $this->get(IEventDispatcher::class);
549
-				$dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
550
-			});
551
-			$userSession->listen('\OC\User', 'postLogout', function ($user) {
552
-				/** @var IEventDispatcher $dispatcher */
553
-				$dispatcher = $this->get(IEventDispatcher::class);
554
-				$dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
555
-			});
556
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
557
-				/** @var \OC\User\User $user */
558
-				\OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
559
-			});
560
-			return $userSession;
561
-		});
562
-		$this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
563
-
564
-		$this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
565
-
566
-		$this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
567
-
568
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
569
-
570
-		$this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
571
-			return new \OC\SystemConfig($config);
572
-		});
573
-
574
-		$this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
575
-		$this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
576
-		$this->registerAlias(IAppManager::class, AppManager::class);
577
-
578
-		$this->registerService(IFactory::class, function (Server $c) {
579
-			return new \OC\L10N\Factory(
580
-				$c->get(\OCP\IConfig::class),
581
-				$c->getRequest(),
582
-				$c->get(IUserSession::class),
583
-				$c->get(ICacheFactory::class),
584
-				\OC::$SERVERROOT,
585
-				$c->get(IAppManager::class),
586
-			);
587
-		});
588
-
589
-		$this->registerAlias(IURLGenerator::class, URLGenerator::class);
590
-
591
-		$this->registerAlias(ICache::class, Cache\File::class);
592
-		$this->registerService(Factory::class, function (Server $c) {
593
-			$profiler = $c->get(IProfiler::class);
594
-			$logger = $c->get(LoggerInterface::class);
595
-			$serverVersion = $c->get(ServerVersion::class);
596
-			/** @var SystemConfig $config */
597
-			$config = $c->get(SystemConfig::class);
598
-			if (!$config->getValue('installed', false) || (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
599
-				return new \OC\Memcache\Factory(
600
-					$logger,
601
-					$profiler,
602
-					$serverVersion,
603
-					ArrayCache::class,
604
-					ArrayCache::class,
605
-					ArrayCache::class
606
-				);
607
-			}
608
-
609
-			return new \OC\Memcache\Factory(
610
-				$logger,
611
-				$profiler,
612
-				$serverVersion,
613
-				/** @psalm-taint-escape callable */
614
-				$config->getValue('memcache.local', null),
615
-				/** @psalm-taint-escape callable */
616
-				$config->getValue('memcache.distributed', null),
617
-				/** @psalm-taint-escape callable */
618
-				$config->getValue('memcache.locking', null),
619
-				/** @psalm-taint-escape callable */
620
-				$config->getValue('redis_log_file')
621
-			);
622
-		});
623
-		$this->registerAlias(ICacheFactory::class, Factory::class);
624
-
625
-		$this->registerService('RedisFactory', function (Server $c) {
626
-			$systemConfig = $c->get(SystemConfig::class);
627
-			return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
628
-		});
629
-
630
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
631
-			$l10n = $this->get(IFactory::class)->get('lib');
632
-			return new \OC\Activity\Manager(
633
-				$c->getRequest(),
634
-				$c->get(IUserSession::class),
635
-				$c->get(\OCP\IConfig::class),
636
-				$c->get(IValidator::class),
637
-				$c->get(IRichTextFormatter::class),
638
-				$l10n,
639
-				$c->get(ITimeFactory::class),
640
-			);
641
-		});
642
-
643
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
644
-			return new \OC\Activity\EventMerger(
645
-				$c->getL10N('lib')
646
-			);
647
-		});
648
-		$this->registerAlias(IValidator::class, Validator::class);
649
-
650
-		$this->registerService(AvatarManager::class, function (Server $c) {
651
-			return new AvatarManager(
652
-				$c->get(IUserSession::class),
653
-				$c->get(\OC\User\Manager::class),
654
-				$c->getAppDataDir('avatar'),
655
-				$c->getL10N('lib'),
656
-				$c->get(LoggerInterface::class),
657
-				$c->get(\OCP\IConfig::class),
658
-				$c->get(IAccountManager::class),
659
-				$c->get(KnownUserService::class)
660
-			);
661
-		});
662
-
663
-		$this->registerAlias(IAvatarManager::class, AvatarManager::class);
664
-
665
-		$this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
666
-		$this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
667
-		$this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
668
-
669
-		/** Only used by the PsrLoggerAdapter should not be used by apps */
670
-		$this->registerService(\OC\Log::class, function (Server $c) {
671
-			$logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
672
-			$factory = new LogFactory($c, $this->get(SystemConfig::class));
673
-			$logger = $factory->get($logType);
674
-			$registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
675
-
676
-			return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
677
-		});
678
-		// PSR-3 logger
679
-		$this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
680
-
681
-		$this->registerService(ILogFactory::class, function (Server $c) {
682
-			return new LogFactory($c, $this->get(SystemConfig::class));
683
-		});
684
-
685
-		$this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
686
-
687
-		$this->registerService(Router::class, function (Server $c) {
688
-			$cacheFactory = $c->get(ICacheFactory::class);
689
-			if ($cacheFactory->isLocalCacheAvailable()) {
690
-				$router = $c->resolve(CachingRouter::class);
691
-			} else {
692
-				$router = $c->resolve(Router::class);
693
-			}
694
-			return $router;
695
-		});
696
-		$this->registerAlias(IRouter::class, Router::class);
697
-
698
-		$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
699
-			$config = $c->get(\OCP\IConfig::class);
700
-			if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
701
-				$backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
702
-					$c->get(AllConfig::class),
703
-					$this->get(ICacheFactory::class),
704
-					new \OC\AppFramework\Utility\TimeFactory()
705
-				);
706
-			} else {
707
-				$backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
708
-					$c->get(AllConfig::class),
709
-					$c->get(IDBConnection::class),
710
-					new \OC\AppFramework\Utility\TimeFactory()
711
-				);
712
-			}
713
-
714
-			return $backend;
715
-		});
716
-
717
-		$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
718
-		$this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
719
-		$this->registerAlias(IVerificationToken::class, VerificationToken::class);
720
-
721
-		$this->registerAlias(ICrypto::class, Crypto::class);
722
-
723
-		$this->registerAlias(IHasher::class, Hasher::class);
724
-
725
-		$this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
726
-
727
-		$this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
728
-		$this->registerService(Connection::class, function (Server $c) {
729
-			$systemConfig = $c->get(SystemConfig::class);
730
-			$factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
731
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
732
-			if (!$factory->isValidType($type)) {
733
-				throw new \OC\DatabaseException('Invalid database type');
734
-			}
735
-			$connection = $factory->getConnection($type, []);
736
-			return $connection;
737
-		});
738
-
739
-		$this->registerAlias(ICertificateManager::class, CertificateManager::class);
740
-		$this->registerAlias(IClientService::class, ClientService::class);
741
-		$this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
742
-			return new NegativeDnsCache(
743
-				$c->get(ICacheFactory::class),
744
-			);
745
-		});
746
-		$this->registerDeprecatedAlias('HttpClientService', IClientService::class);
747
-		$this->registerService(IEventLogger::class, function (ContainerInterface $c) {
748
-			return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
749
-		});
750
-
751
-		$this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
752
-			$queryLogger = new QueryLogger();
753
-			if ($c->get(SystemConfig::class)->getValue('debug', false)) {
754
-				// In debug mode, module is being activated by default
755
-				$queryLogger->activate();
756
-			}
757
-			return $queryLogger;
758
-		});
759
-
760
-		$this->registerAlias(ITempManager::class, TempManager::class);
761
-		$this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
762
-
763
-		$this->registerService(IDateTimeFormatter::class, function (Server $c) {
764
-			$language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
765
-
766
-			return new DateTimeFormatter(
767
-				$c->get(IDateTimeZone::class)->getTimeZone(),
768
-				$c->getL10N('lib', $language)
769
-			);
770
-		});
771
-
772
-		$this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
773
-			$mountCache = $c->get(UserMountCache::class);
774
-			$listener = new UserMountCacheListener($mountCache);
775
-			$listener->listen($c->get(IUserManager::class));
776
-			return $mountCache;
777
-		});
778
-
779
-		$this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
780
-			$loader = $c->get(IStorageFactory::class);
781
-			$mountCache = $c->get(IUserMountCache::class);
782
-			$eventLogger = $c->get(IEventLogger::class);
783
-			$manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
784
-
785
-			// builtin providers
786
-
787
-			$config = $c->get(\OCP\IConfig::class);
788
-			$logger = $c->get(LoggerInterface::class);
789
-			$objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
790
-			$manager->registerProvider(new CacheMountProvider($config));
791
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
792
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
793
-			$manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
794
-
795
-			return $manager;
796
-		});
797
-
798
-		$this->registerService(IBus::class, function (ContainerInterface $c) {
799
-			$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
800
-			if ($busClass) {
801
-				[$app, $class] = explode('::', $busClass, 2);
802
-				if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
803
-					$c->get(IAppManager::class)->loadApp($app);
804
-					return $c->get($class);
805
-				} else {
806
-					throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
807
-				}
808
-			} else {
809
-				$jobList = $c->get(IJobList::class);
810
-				return new CronBus($jobList);
811
-			}
812
-		});
813
-		$this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
814
-		$this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
815
-		$this->registerAlias(IThrottler::class, Throttler::class);
816
-
817
-		$this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
818
-			$config = $c->get(\OCP\IConfig::class);
819
-			if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
820
-				&& ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
821
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
822
-			} else {
823
-				$backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
824
-			}
825
-
826
-			return $backend;
827
-		});
828
-
829
-		$this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
830
-		$this->registerService(Checker::class, function (ContainerInterface $c) {
831
-			// IConfig requires a working database. This code
832
-			// might however be called when Nextcloud is not yet setup.
833
-			if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
834
-				$config = $c->get(\OCP\IConfig::class);
835
-				$appConfig = $c->get(\OCP\IAppConfig::class);
836
-			} else {
837
-				$config = null;
838
-				$appConfig = null;
839
-			}
840
-
841
-			return new Checker(
842
-				$c->get(ServerVersion::class),
843
-				$c->get(EnvironmentHelper::class),
844
-				new FileAccessHelper(),
845
-				$config,
846
-				$appConfig,
847
-				$c->get(ICacheFactory::class),
848
-				$c->get(IAppManager::class),
849
-				$c->get(IMimeTypeDetector::class)
850
-			);
851
-		});
852
-		$this->registerService(Request::class, function (ContainerInterface $c) {
853
-			if (isset($this['urlParams'])) {
854
-				$urlParams = $this['urlParams'];
855
-			} else {
856
-				$urlParams = [];
857
-			}
858
-
859
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
860
-				&& in_array('fakeinput', stream_get_wrappers())
861
-			) {
862
-				$stream = 'fakeinput://data';
863
-			} else {
864
-				$stream = 'php://input';
865
-			}
866
-
867
-			return new Request(
868
-				[
869
-					'get' => $_GET,
870
-					'post' => $_POST,
871
-					'files' => $_FILES,
872
-					'server' => $_SERVER,
873
-					'env' => $_ENV,
874
-					'cookies' => $_COOKIE,
875
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
876
-						? $_SERVER['REQUEST_METHOD']
877
-						: '',
878
-					'urlParams' => $urlParams,
879
-				],
880
-				$this->get(IRequestId::class),
881
-				$this->get(\OCP\IConfig::class),
882
-				$this->get(CsrfTokenManager::class),
883
-				$stream
884
-			);
885
-		});
886
-		$this->registerAlias(\OCP\IRequest::class, Request::class);
887
-
888
-		$this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
889
-			return new RequestId(
890
-				$_SERVER['UNIQUE_ID'] ?? '',
891
-				$this->get(ISecureRandom::class)
892
-			);
893
-		});
894
-
895
-		/** @since 32.0.0 */
896
-		$this->registerAlias(IEmailValidator::class, EmailValidator::class);
897
-
898
-		$this->registerService(IMailer::class, function (Server $c) {
899
-			return new Mailer(
900
-				$c->get(\OCP\IConfig::class),
901
-				$c->get(LoggerInterface::class),
902
-				$c->get(Defaults::class),
903
-				$c->get(IURLGenerator::class),
904
-				$c->getL10N('lib'),
905
-				$c->get(IEventDispatcher::class),
906
-				$c->get(IFactory::class),
907
-				$c->get(IEmailValidator::class),
908
-			);
909
-		});
910
-
911
-		/** @since 30.0.0 */
912
-		$this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
913
-
914
-		$this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
915
-			$config = $c->get(\OCP\IConfig::class);
916
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
917
-			if (is_null($factoryClass) || !class_exists($factoryClass)) {
918
-				return new NullLDAPProviderFactory($this);
919
-			}
920
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
921
-			return new $factoryClass($this);
922
-		});
923
-		$this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
924
-			$factory = $c->get(ILDAPProviderFactory::class);
925
-			return $factory->getLDAPProvider();
926
-		});
927
-		$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
928
-			$ini = $c->get(IniGetWrapper::class);
929
-			$config = $c->get(\OCP\IConfig::class);
930
-			$ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
931
-			if ($config->getSystemValueBool('filelocking.enabled', true) || (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
932
-				/** @var \OC\Memcache\Factory $memcacheFactory */
933
-				$memcacheFactory = $c->get(ICacheFactory::class);
934
-				$memcache = $memcacheFactory->createLocking('lock');
935
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
936
-					$timeFactory = $c->get(ITimeFactory::class);
937
-					return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
938
-				}
939
-				return new DBLockingProvider(
940
-					$c->get(IDBConnection::class),
941
-					new TimeFactory(),
942
-					$ttl,
943
-					!\OC::$CLI
944
-				);
945
-			}
946
-			return new NoopLockingProvider();
947
-		});
948
-
949
-		$this->registerService(ILockManager::class, function (Server $c): LockManager {
950
-			return new LockManager();
951
-		});
952
-
953
-		$this->registerAlias(ILockdownManager::class, 'LockdownManager');
954
-		$this->registerService(SetupManager::class, function ($c) {
955
-			// create the setupmanager through the mount manager to resolve the cyclic dependency
956
-			return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
957
-		});
958
-		$this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
959
-
960
-		$this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
961
-			return new \OC\Files\Type\Detection(
962
-				$c->get(IURLGenerator::class),
963
-				$c->get(LoggerInterface::class),
964
-				\OC::$configDir,
965
-				\OC::$SERVERROOT . '/resources/config/'
966
-			);
967
-		});
968
-
969
-		$this->registerAlias(IMimeTypeLoader::class, Loader::class);
970
-		$this->registerService(BundleFetcher::class, function () {
971
-			return new BundleFetcher($this->getL10N('lib'));
972
-		});
973
-		$this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
974
-
975
-		$this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
976
-			$manager = new CapabilitiesManager($c->get(LoggerInterface::class));
977
-			$manager->registerCapability(function () use ($c) {
978
-				return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
979
-			});
980
-			$manager->registerCapability(function () use ($c) {
981
-				return $c->get(\OC\Security\Bruteforce\Capabilities::class);
982
-			});
983
-			return $manager;
984
-		});
985
-
986
-		$this->registerService(ICommentsManager::class, function (Server $c) {
987
-			$config = $c->get(\OCP\IConfig::class);
988
-			$factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
989
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
990
-			$factory = new $factoryClass($this);
991
-			$manager = $factory->getManager();
992
-
993
-			$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
994
-				$manager = $c->get(IUserManager::class);
995
-				$userDisplayName = $manager->getDisplayName($id);
996
-				if ($userDisplayName === null) {
997
-					$l = $c->get(IFactory::class)->get('core');
998
-					return $l->t('Unknown account');
999
-				}
1000
-				return $userDisplayName;
1001
-			});
1002
-
1003
-			return $manager;
1004
-		});
1005
-
1006
-		$this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1007
-		$this->registerService('ThemingDefaults', function (Server $c) {
1008
-			try {
1009
-				$classExists = class_exists('OCA\Theming\ThemingDefaults');
1010
-			} catch (\OCP\AutoloadNotAllowedException $e) {
1011
-				// App disabled or in maintenance mode
1012
-				$classExists = false;
1013
-			}
1014
-
1015
-			if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1016
-				$backgroundService = new BackgroundService(
1017
-					$c->get(IRootFolder::class),
1018
-					$c->get(IAppDataFactory::class)->get('theming'),
1019
-					$c->get(IAppConfig::class),
1020
-					$c->get(\OCP\IConfig::class),
1021
-					$c->get(ISession::class)->get('user_id'),
1022
-				);
1023
-				$imageManager = new ImageManager(
1024
-					$c->get(\OCP\IConfig::class),
1025
-					$c->get(IAppDataFactory::class)->get('theming'),
1026
-					$c->get(IURLGenerator::class),
1027
-					$c->get(ICacheFactory::class),
1028
-					$c->get(LoggerInterface::class),
1029
-					$c->get(ITempManager::class),
1030
-					$backgroundService,
1031
-				);
1032
-				return new ThemingDefaults(
1033
-					$c->get(\OCP\IConfig::class),
1034
-					new AppConfig(
1035
-						$c->get(\OCP\IConfig::class),
1036
-						$c->get(\OCP\IAppConfig::class),
1037
-						'theming',
1038
-					),
1039
-					$c->get(IFactory::class)->get('theming'),
1040
-					$c->get(IUserSession::class),
1041
-					$c->get(IURLGenerator::class),
1042
-					$c->get(ICacheFactory::class),
1043
-					new Util(
1044
-						$c->get(ServerVersion::class),
1045
-						$c->get(\OCP\IConfig::class),
1046
-						$this->get(IAppManager::class),
1047
-						$c->get(IAppDataFactory::class)->get('theming'),
1048
-						$imageManager,
1049
-					),
1050
-					$imageManager,
1051
-					$c->get(IAppManager::class),
1052
-					$c->get(INavigationManager::class),
1053
-					$backgroundService,
1054
-				);
1055
-			}
1056
-			return new \OC_Defaults();
1057
-		});
1058
-		$this->registerService(JSCombiner::class, function (Server $c) {
1059
-			return new JSCombiner(
1060
-				$c->getAppDataDir('js'),
1061
-				$c->get(IURLGenerator::class),
1062
-				$this->get(ICacheFactory::class),
1063
-				$c->get(\OCP\IConfig::class),
1064
-				$c->get(LoggerInterface::class)
1065
-			);
1066
-		});
1067
-		$this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1068
-
1069
-		$this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1070
-			// FIXME: Instantiated here due to cyclic dependency
1071
-			$request = new Request(
1072
-				[
1073
-					'get' => $_GET,
1074
-					'post' => $_POST,
1075
-					'files' => $_FILES,
1076
-					'server' => $_SERVER,
1077
-					'env' => $_ENV,
1078
-					'cookies' => $_COOKIE,
1079
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1080
-						? $_SERVER['REQUEST_METHOD']
1081
-						: null,
1082
-				],
1083
-				$c->get(IRequestId::class),
1084
-				$c->get(\OCP\IConfig::class)
1085
-			);
1086
-
1087
-			return new CryptoWrapper(
1088
-				$c->get(ICrypto::class),
1089
-				$c->get(ISecureRandom::class),
1090
-				$request
1091
-			);
1092
-		});
1093
-		$this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1094
-			return new SessionStorage($c->get(ISession::class));
1095
-		});
1096
-		$this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1097
-
1098
-		$this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1099
-			$config = $c->get(\OCP\IConfig::class);
1100
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1101
-			/** @var \OCP\Share\IProviderFactory $factory */
1102
-			return $c->get($factoryClass);
1103
-		});
1104
-
1105
-		$this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1106
-
1107
-		$this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1108
-			$instance = new Collaboration\Collaborators\Search($c);
1109
-
1110
-			// register default plugins
1111
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1112
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1113
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1114
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1115
-			$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1116
-
1117
-			return $instance;
1118
-		});
1119
-		$this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1120
-
1121
-		$this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1122
-
1123
-		$this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1124
-		$this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1125
-
1126
-		$this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1127
-		$this->registerAlias(ITeamManager::class, TeamManager::class);
1128
-
1129
-		$this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1130
-		$this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1131
-		$this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1132
-			return new \OC\Files\AppData\Factory(
1133
-				$c->get(IRootFolder::class),
1134
-				$c->get(SystemConfig::class)
1135
-			);
1136
-		});
1137
-
1138
-		$this->registerService('LockdownManager', function (ContainerInterface $c) {
1139
-			return new LockdownManager(function () use ($c) {
1140
-				return $c->get(ISession::class);
1141
-			});
1142
-		});
1143
-
1144
-		$this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1145
-			return new DiscoveryService(
1146
-				$c->get(ICacheFactory::class),
1147
-				$c->get(IClientService::class)
1148
-			);
1149
-		});
1150
-		$this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1151
-
1152
-		$this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1153
-			return new CloudIdManager(
1154
-				$c->get(ICacheFactory::class),
1155
-				$c->get(IEventDispatcher::class),
1156
-				$c->get(\OCP\Contacts\IManager::class),
1157
-				$c->get(IURLGenerator::class),
1158
-				$c->get(IUserManager::class),
1159
-			);
1160
-		});
258
+    /** @var string */
259
+    private $webRoot;
260
+
261
+    /**
262
+     * @param string $webRoot
263
+     * @param \OC\Config $config
264
+     */
265
+    public function __construct($webRoot, \OC\Config $config) {
266
+        parent::__construct();
267
+        $this->webRoot = $webRoot;
268
+
269
+        // To find out if we are running from CLI or not
270
+        $this->registerParameter('isCLI', \OC::$CLI);
271
+        $this->registerParameter('serverRoot', \OC::$SERVERROOT);
272
+
273
+        $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
274
+            return $c;
275
+        });
276
+        $this->registerDeprecatedAlias(\OCP\IServerContainer::class, ContainerInterface::class);
277
+
278
+        $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
279
+
280
+        $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
281
+
282
+        $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
283
+
284
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
285
+
286
+        $this->registerAlias(\OCP\ContextChat\IContentManager::class, \OC\ContextChat\ContentManager::class);
287
+
288
+        $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
289
+        $this->registerAlias(ITemplateManager::class, TemplateManager::class);
290
+        $this->registerAlias(\OCP\Template\ITemplateManager::class, \OC\Template\TemplateManager::class);
291
+
292
+        $this->registerAlias(IActionFactory::class, ActionFactory::class);
293
+
294
+        $this->registerService(View::class, function (Server $c) {
295
+            return new View();
296
+        }, false);
297
+
298
+        $this->registerService(IPreview::class, function (ContainerInterface $c) {
299
+            return new PreviewManager(
300
+                $c->get(\OCP\IConfig::class),
301
+                $c->get(IRootFolder::class),
302
+                $c->get(IEventDispatcher::class),
303
+                $c->get(GeneratorHelper::class),
304
+                $c->get(ISession::class)->get('user_id'),
305
+                $c->get(Coordinator::class),
306
+                $c->get(IServerContainer::class),
307
+                $c->get(IBinaryFinder::class),
308
+                $c->get(IMagickSupport::class)
309
+            );
310
+        });
311
+        $this->registerAlias(IMimeIconProvider::class, MimeIconProvider::class);
312
+
313
+        $this->registerService(Watcher::class, function (ContainerInterface $c): Watcher {
314
+            return new Watcher(
315
+                $c->get(\OC\Preview\Storage\StorageFactory::class),
316
+                $c->get(PreviewMapper::class),
317
+                $c->get(IDBConnection::class),
318
+            );
319
+        });
320
+
321
+        $this->registerService(IProfiler::class, function (Server $c) {
322
+            return new Profiler($c->get(SystemConfig::class));
323
+        });
324
+
325
+        $this->registerService(Encryption\Manager::class, function (Server $c): Encryption\Manager {
326
+            $view = new View();
327
+            $util = new Encryption\Util(
328
+                $view,
329
+                $c->get(IUserManager::class),
330
+                $c->get(IGroupManager::class),
331
+                $c->get(\OCP\IConfig::class)
332
+            );
333
+            return new Encryption\Manager(
334
+                $c->get(\OCP\IConfig::class),
335
+                $c->get(LoggerInterface::class),
336
+                $c->getL10N('core'),
337
+                new View(),
338
+                $util,
339
+                new ArrayCache()
340
+            );
341
+        });
342
+        $this->registerAlias(\OCP\Encryption\IManager::class, Encryption\Manager::class);
343
+
344
+        $this->registerService(IFile::class, function (ContainerInterface $c) {
345
+            $util = new Encryption\Util(
346
+                new View(),
347
+                $c->get(IUserManager::class),
348
+                $c->get(IGroupManager::class),
349
+                $c->get(\OCP\IConfig::class)
350
+            );
351
+            return new Encryption\File(
352
+                $util,
353
+                $c->get(IRootFolder::class),
354
+                $c->get(\OCP\Share\IManager::class)
355
+            );
356
+        });
357
+
358
+        $this->registerService(IStorage::class, function (ContainerInterface $c) {
359
+            $view = new View();
360
+            $util = new Encryption\Util(
361
+                $view,
362
+                $c->get(IUserManager::class),
363
+                $c->get(IGroupManager::class),
364
+                $c->get(\OCP\IConfig::class)
365
+            );
366
+
367
+            return new Encryption\Keys\Storage(
368
+                $view,
369
+                $util,
370
+                $c->get(ICrypto::class),
371
+                $c->get(\OCP\IConfig::class)
372
+            );
373
+        });
374
+
375
+        $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
376
+
377
+        $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
378
+            /** @var \OCP\IConfig $config */
379
+            $config = $c->get(\OCP\IConfig::class);
380
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
381
+            return new $factoryClass($this);
382
+        });
383
+        $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
384
+            return $c->get('SystemTagManagerFactory')->getManager();
385
+        });
386
+        /** @deprecated 19.0.0 */
387
+        $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
388
+
389
+        $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
390
+            return $c->get('SystemTagManagerFactory')->getObjectMapper();
391
+        });
392
+        $this->registerAlias(IFileAccess::class, FileAccess::class);
393
+        $this->registerService('RootFolder', function (ContainerInterface $c) {
394
+            $manager = \OC\Files\Filesystem::getMountManager();
395
+            $view = new View();
396
+            /** @var IUserSession $userSession */
397
+            $userSession = $c->get(IUserSession::class);
398
+            $root = new Root(
399
+                $manager,
400
+                $view,
401
+                $userSession->getUser(),
402
+                $c->get(IUserMountCache::class),
403
+                $this->get(LoggerInterface::class),
404
+                $this->get(IUserManager::class),
405
+                $this->get(IEventDispatcher::class),
406
+                $this->get(ICacheFactory::class),
407
+                $this->get(IAppConfig::class),
408
+            );
409
+
410
+            $previewConnector = new \OC\Preview\WatcherConnector(
411
+                $root,
412
+                $c->get(SystemConfig::class),
413
+                $this->get(IEventDispatcher::class)
414
+            );
415
+            $previewConnector->connectWatcher();
416
+
417
+            return $root;
418
+        });
419
+        $this->registerService(HookConnector::class, function (ContainerInterface $c) {
420
+            return new HookConnector(
421
+                $c->get(IRootFolder::class),
422
+                new View(),
423
+                $c->get(IEventDispatcher::class),
424
+                $c->get(LoggerInterface::class)
425
+            );
426
+        });
427
+
428
+        $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
429
+            return new LazyRoot(function () use ($c) {
430
+                return $c->get('RootFolder');
431
+            });
432
+        });
433
+
434
+        $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
435
+
436
+        $this->registerService(DisplayNameCache::class, function (ContainerInterface $c) {
437
+            return $c->get(\OC\User\Manager::class)->getDisplayNameCache();
438
+        });
439
+
440
+        $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
441
+            $groupManager = new \OC\Group\Manager(
442
+                $this->get(IUserManager::class),
443
+                $this->get(IEventDispatcher::class),
444
+                $this->get(LoggerInterface::class),
445
+                $this->get(ICacheFactory::class),
446
+                $this->get(IRemoteAddress::class),
447
+            );
448
+            return $groupManager;
449
+        });
450
+
451
+        $this->registerService(Store::class, function (ContainerInterface $c) {
452
+            $session = $c->get(ISession::class);
453
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
454
+                $tokenProvider = $c->get(IProvider::class);
455
+            } else {
456
+                $tokenProvider = null;
457
+            }
458
+            $logger = $c->get(LoggerInterface::class);
459
+            $crypto = $c->get(ICrypto::class);
460
+            return new Store($session, $logger, $crypto, $tokenProvider);
461
+        });
462
+        $this->registerAlias(IStore::class, Store::class);
463
+        $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
464
+        $this->registerAlias(OCPIProvider::class, Authentication\Token\Manager::class);
465
+
466
+        $this->registerService(\OC\User\Session::class, function (Server $c) {
467
+            $manager = $c->get(IUserManager::class);
468
+            $session = new \OC\Session\Memory();
469
+            $timeFactory = new TimeFactory();
470
+            // Token providers might require a working database. This code
471
+            // might however be called when Nextcloud is not yet setup.
472
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
473
+                $provider = $c->get(IProvider::class);
474
+            } else {
475
+                $provider = null;
476
+            }
477
+
478
+            $userSession = new \OC\User\Session(
479
+                $manager,
480
+                $session,
481
+                $timeFactory,
482
+                $provider,
483
+                $c->get(\OCP\IConfig::class),
484
+                $c->get(ISecureRandom::class),
485
+                $c->get('LockdownManager'),
486
+                $c->get(LoggerInterface::class),
487
+                $c->get(IEventDispatcher::class),
488
+            );
489
+            /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
490
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
491
+                \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
492
+            });
493
+            /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
494
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
495
+                /** @var \OC\User\User $user */
496
+                \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
497
+            });
498
+            /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
499
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
500
+                /** @var \OC\User\User $user */
501
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
502
+            });
503
+            /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
504
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
505
+                /** @var \OC\User\User $user */
506
+                \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
507
+            });
508
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
509
+                /** @var \OC\User\User $user */
510
+                \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
511
+            });
512
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
513
+                /** @var \OC\User\User $user */
514
+                \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
515
+            });
516
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
517
+                \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
518
+
519
+                /** @var IEventDispatcher $dispatcher */
520
+                $dispatcher = $this->get(IEventDispatcher::class);
521
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
522
+            });
523
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
524
+                /** @var \OC\User\User $user */
525
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
526
+
527
+                /** @var IEventDispatcher $dispatcher */
528
+                $dispatcher = $this->get(IEventDispatcher::class);
529
+                $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
530
+            });
531
+            $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
532
+                /** @var IEventDispatcher $dispatcher */
533
+                $dispatcher = $this->get(IEventDispatcher::class);
534
+                $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
535
+            });
536
+            $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
537
+                /** @var \OC\User\User $user */
538
+                \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
539
+
540
+                /** @var IEventDispatcher $dispatcher */
541
+                $dispatcher = $this->get(IEventDispatcher::class);
542
+                $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
543
+            });
544
+            $userSession->listen('\OC\User', 'logout', function ($user) {
545
+                \OC_Hook::emit('OC_User', 'logout', []);
546
+
547
+                /** @var IEventDispatcher $dispatcher */
548
+                $dispatcher = $this->get(IEventDispatcher::class);
549
+                $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
550
+            });
551
+            $userSession->listen('\OC\User', 'postLogout', function ($user) {
552
+                /** @var IEventDispatcher $dispatcher */
553
+                $dispatcher = $this->get(IEventDispatcher::class);
554
+                $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
555
+            });
556
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
557
+                /** @var \OC\User\User $user */
558
+                \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
559
+            });
560
+            return $userSession;
561
+        });
562
+        $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
563
+
564
+        $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
565
+
566
+        $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
567
+
568
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
569
+
570
+        $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
571
+            return new \OC\SystemConfig($config);
572
+        });
573
+
574
+        $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
575
+        $this->registerAlias(IUserConfig::class, \OC\Config\UserConfig::class);
576
+        $this->registerAlias(IAppManager::class, AppManager::class);
577
+
578
+        $this->registerService(IFactory::class, function (Server $c) {
579
+            return new \OC\L10N\Factory(
580
+                $c->get(\OCP\IConfig::class),
581
+                $c->getRequest(),
582
+                $c->get(IUserSession::class),
583
+                $c->get(ICacheFactory::class),
584
+                \OC::$SERVERROOT,
585
+                $c->get(IAppManager::class),
586
+            );
587
+        });
588
+
589
+        $this->registerAlias(IURLGenerator::class, URLGenerator::class);
590
+
591
+        $this->registerAlias(ICache::class, Cache\File::class);
592
+        $this->registerService(Factory::class, function (Server $c) {
593
+            $profiler = $c->get(IProfiler::class);
594
+            $logger = $c->get(LoggerInterface::class);
595
+            $serverVersion = $c->get(ServerVersion::class);
596
+            /** @var SystemConfig $config */
597
+            $config = $c->get(SystemConfig::class);
598
+            if (!$config->getValue('installed', false) || (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
599
+                return new \OC\Memcache\Factory(
600
+                    $logger,
601
+                    $profiler,
602
+                    $serverVersion,
603
+                    ArrayCache::class,
604
+                    ArrayCache::class,
605
+                    ArrayCache::class
606
+                );
607
+            }
608
+
609
+            return new \OC\Memcache\Factory(
610
+                $logger,
611
+                $profiler,
612
+                $serverVersion,
613
+                /** @psalm-taint-escape callable */
614
+                $config->getValue('memcache.local', null),
615
+                /** @psalm-taint-escape callable */
616
+                $config->getValue('memcache.distributed', null),
617
+                /** @psalm-taint-escape callable */
618
+                $config->getValue('memcache.locking', null),
619
+                /** @psalm-taint-escape callable */
620
+                $config->getValue('redis_log_file')
621
+            );
622
+        });
623
+        $this->registerAlias(ICacheFactory::class, Factory::class);
624
+
625
+        $this->registerService('RedisFactory', function (Server $c) {
626
+            $systemConfig = $c->get(SystemConfig::class);
627
+            return new RedisFactory($systemConfig, $c->get(IEventLogger::class));
628
+        });
629
+
630
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
631
+            $l10n = $this->get(IFactory::class)->get('lib');
632
+            return new \OC\Activity\Manager(
633
+                $c->getRequest(),
634
+                $c->get(IUserSession::class),
635
+                $c->get(\OCP\IConfig::class),
636
+                $c->get(IValidator::class),
637
+                $c->get(IRichTextFormatter::class),
638
+                $l10n,
639
+                $c->get(ITimeFactory::class),
640
+            );
641
+        });
642
+
643
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
644
+            return new \OC\Activity\EventMerger(
645
+                $c->getL10N('lib')
646
+            );
647
+        });
648
+        $this->registerAlias(IValidator::class, Validator::class);
649
+
650
+        $this->registerService(AvatarManager::class, function (Server $c) {
651
+            return new AvatarManager(
652
+                $c->get(IUserSession::class),
653
+                $c->get(\OC\User\Manager::class),
654
+                $c->getAppDataDir('avatar'),
655
+                $c->getL10N('lib'),
656
+                $c->get(LoggerInterface::class),
657
+                $c->get(\OCP\IConfig::class),
658
+                $c->get(IAccountManager::class),
659
+                $c->get(KnownUserService::class)
660
+            );
661
+        });
662
+
663
+        $this->registerAlias(IAvatarManager::class, AvatarManager::class);
664
+
665
+        $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
666
+        $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
667
+        $this->registerAlias(\OCP\Support\Subscription\IAssertion::class, \OC\Support\Subscription\Assertion::class);
668
+
669
+        /** Only used by the PsrLoggerAdapter should not be used by apps */
670
+        $this->registerService(\OC\Log::class, function (Server $c) {
671
+            $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
672
+            $factory = new LogFactory($c, $this->get(SystemConfig::class));
673
+            $logger = $factory->get($logType);
674
+            $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
675
+
676
+            return new Log($logger, $this->get(SystemConfig::class), crashReporters: $registry);
677
+        });
678
+        // PSR-3 logger
679
+        $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
680
+
681
+        $this->registerService(ILogFactory::class, function (Server $c) {
682
+            return new LogFactory($c, $this->get(SystemConfig::class));
683
+        });
684
+
685
+        $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
686
+
687
+        $this->registerService(Router::class, function (Server $c) {
688
+            $cacheFactory = $c->get(ICacheFactory::class);
689
+            if ($cacheFactory->isLocalCacheAvailable()) {
690
+                $router = $c->resolve(CachingRouter::class);
691
+            } else {
692
+                $router = $c->resolve(Router::class);
693
+            }
694
+            return $router;
695
+        });
696
+        $this->registerAlias(IRouter::class, Router::class);
697
+
698
+        $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
699
+            $config = $c->get(\OCP\IConfig::class);
700
+            if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
701
+                $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
702
+                    $c->get(AllConfig::class),
703
+                    $this->get(ICacheFactory::class),
704
+                    new \OC\AppFramework\Utility\TimeFactory()
705
+                );
706
+            } else {
707
+                $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
708
+                    $c->get(AllConfig::class),
709
+                    $c->get(IDBConnection::class),
710
+                    new \OC\AppFramework\Utility\TimeFactory()
711
+                );
712
+            }
713
+
714
+            return $backend;
715
+        });
716
+
717
+        $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
718
+        $this->registerAlias(\OCP\Security\IRemoteHostValidator::class, \OC\Security\RemoteHostValidator::class);
719
+        $this->registerAlias(IVerificationToken::class, VerificationToken::class);
720
+
721
+        $this->registerAlias(ICrypto::class, Crypto::class);
722
+
723
+        $this->registerAlias(IHasher::class, Hasher::class);
724
+
725
+        $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
726
+
727
+        $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
728
+        $this->registerService(Connection::class, function (Server $c) {
729
+            $systemConfig = $c->get(SystemConfig::class);
730
+            $factory = new \OC\DB\ConnectionFactory($systemConfig, $c->get(ICacheFactory::class));
731
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
732
+            if (!$factory->isValidType($type)) {
733
+                throw new \OC\DatabaseException('Invalid database type');
734
+            }
735
+            $connection = $factory->getConnection($type, []);
736
+            return $connection;
737
+        });
738
+
739
+        $this->registerAlias(ICertificateManager::class, CertificateManager::class);
740
+        $this->registerAlias(IClientService::class, ClientService::class);
741
+        $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
742
+            return new NegativeDnsCache(
743
+                $c->get(ICacheFactory::class),
744
+            );
745
+        });
746
+        $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
747
+        $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
748
+            return new EventLogger($c->get(SystemConfig::class), $c->get(LoggerInterface::class), $c->get(Log::class));
749
+        });
750
+
751
+        $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
752
+            $queryLogger = new QueryLogger();
753
+            if ($c->get(SystemConfig::class)->getValue('debug', false)) {
754
+                // In debug mode, module is being activated by default
755
+                $queryLogger->activate();
756
+            }
757
+            return $queryLogger;
758
+        });
759
+
760
+        $this->registerAlias(ITempManager::class, TempManager::class);
761
+        $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
762
+
763
+        $this->registerService(IDateTimeFormatter::class, function (Server $c) {
764
+            $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
765
+
766
+            return new DateTimeFormatter(
767
+                $c->get(IDateTimeZone::class)->getTimeZone(),
768
+                $c->getL10N('lib', $language)
769
+            );
770
+        });
771
+
772
+        $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
773
+            $mountCache = $c->get(UserMountCache::class);
774
+            $listener = new UserMountCacheListener($mountCache);
775
+            $listener->listen($c->get(IUserManager::class));
776
+            return $mountCache;
777
+        });
778
+
779
+        $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
780
+            $loader = $c->get(IStorageFactory::class);
781
+            $mountCache = $c->get(IUserMountCache::class);
782
+            $eventLogger = $c->get(IEventLogger::class);
783
+            $manager = new MountProviderCollection($loader, $mountCache, $eventLogger);
784
+
785
+            // builtin providers
786
+
787
+            $config = $c->get(\OCP\IConfig::class);
788
+            $logger = $c->get(LoggerInterface::class);
789
+            $objectStoreConfig = $c->get(PrimaryObjectStoreConfig::class);
790
+            $manager->registerProvider(new CacheMountProvider($config));
791
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
792
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($objectStoreConfig));
793
+            $manager->registerRootProvider(new RootMountProvider($objectStoreConfig, $config));
794
+
795
+            return $manager;
796
+        });
797
+
798
+        $this->registerService(IBus::class, function (ContainerInterface $c) {
799
+            $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
800
+            if ($busClass) {
801
+                [$app, $class] = explode('::', $busClass, 2);
802
+                if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
803
+                    $c->get(IAppManager::class)->loadApp($app);
804
+                    return $c->get($class);
805
+                } else {
806
+                    throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
807
+                }
808
+            } else {
809
+                $jobList = $c->get(IJobList::class);
810
+                return new CronBus($jobList);
811
+            }
812
+        });
813
+        $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
814
+        $this->registerAlias(ITrustedDomainHelper::class, TrustedDomainHelper::class);
815
+        $this->registerAlias(IThrottler::class, Throttler::class);
816
+
817
+        $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
818
+            $config = $c->get(\OCP\IConfig::class);
819
+            if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
820
+                && ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
821
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
822
+            } else {
823
+                $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
824
+            }
825
+
826
+            return $backend;
827
+        });
828
+
829
+        $this->registerDeprecatedAlias('IntegrityCodeChecker', Checker::class);
830
+        $this->registerService(Checker::class, function (ContainerInterface $c) {
831
+            // IConfig requires a working database. This code
832
+            // might however be called when Nextcloud is not yet setup.
833
+            if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
834
+                $config = $c->get(\OCP\IConfig::class);
835
+                $appConfig = $c->get(\OCP\IAppConfig::class);
836
+            } else {
837
+                $config = null;
838
+                $appConfig = null;
839
+            }
840
+
841
+            return new Checker(
842
+                $c->get(ServerVersion::class),
843
+                $c->get(EnvironmentHelper::class),
844
+                new FileAccessHelper(),
845
+                $config,
846
+                $appConfig,
847
+                $c->get(ICacheFactory::class),
848
+                $c->get(IAppManager::class),
849
+                $c->get(IMimeTypeDetector::class)
850
+            );
851
+        });
852
+        $this->registerService(Request::class, function (ContainerInterface $c) {
853
+            if (isset($this['urlParams'])) {
854
+                $urlParams = $this['urlParams'];
855
+            } else {
856
+                $urlParams = [];
857
+            }
858
+
859
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
860
+                && in_array('fakeinput', stream_get_wrappers())
861
+            ) {
862
+                $stream = 'fakeinput://data';
863
+            } else {
864
+                $stream = 'php://input';
865
+            }
866
+
867
+            return new Request(
868
+                [
869
+                    'get' => $_GET,
870
+                    'post' => $_POST,
871
+                    'files' => $_FILES,
872
+                    'server' => $_SERVER,
873
+                    'env' => $_ENV,
874
+                    'cookies' => $_COOKIE,
875
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
876
+                        ? $_SERVER['REQUEST_METHOD']
877
+                        : '',
878
+                    'urlParams' => $urlParams,
879
+                ],
880
+                $this->get(IRequestId::class),
881
+                $this->get(\OCP\IConfig::class),
882
+                $this->get(CsrfTokenManager::class),
883
+                $stream
884
+            );
885
+        });
886
+        $this->registerAlias(\OCP\IRequest::class, Request::class);
887
+
888
+        $this->registerService(IRequestId::class, function (ContainerInterface $c): IRequestId {
889
+            return new RequestId(
890
+                $_SERVER['UNIQUE_ID'] ?? '',
891
+                $this->get(ISecureRandom::class)
892
+            );
893
+        });
894
+
895
+        /** @since 32.0.0 */
896
+        $this->registerAlias(IEmailValidator::class, EmailValidator::class);
897
+
898
+        $this->registerService(IMailer::class, function (Server $c) {
899
+            return new Mailer(
900
+                $c->get(\OCP\IConfig::class),
901
+                $c->get(LoggerInterface::class),
902
+                $c->get(Defaults::class),
903
+                $c->get(IURLGenerator::class),
904
+                $c->getL10N('lib'),
905
+                $c->get(IEventDispatcher::class),
906
+                $c->get(IFactory::class),
907
+                $c->get(IEmailValidator::class),
908
+            );
909
+        });
910
+
911
+        /** @since 30.0.0 */
912
+        $this->registerAlias(\OCP\Mail\Provider\IManager::class, \OC\Mail\Provider\Manager::class);
913
+
914
+        $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
915
+            $config = $c->get(\OCP\IConfig::class);
916
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
917
+            if (is_null($factoryClass) || !class_exists($factoryClass)) {
918
+                return new NullLDAPProviderFactory($this);
919
+            }
920
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
921
+            return new $factoryClass($this);
922
+        });
923
+        $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
924
+            $factory = $c->get(ILDAPProviderFactory::class);
925
+            return $factory->getLDAPProvider();
926
+        });
927
+        $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
928
+            $ini = $c->get(IniGetWrapper::class);
929
+            $config = $c->get(\OCP\IConfig::class);
930
+            $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
931
+            if ($config->getSystemValueBool('filelocking.enabled', true) || (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
932
+                /** @var \OC\Memcache\Factory $memcacheFactory */
933
+                $memcacheFactory = $c->get(ICacheFactory::class);
934
+                $memcache = $memcacheFactory->createLocking('lock');
935
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
936
+                    $timeFactory = $c->get(ITimeFactory::class);
937
+                    return new MemcacheLockingProvider($memcache, $timeFactory, $ttl);
938
+                }
939
+                return new DBLockingProvider(
940
+                    $c->get(IDBConnection::class),
941
+                    new TimeFactory(),
942
+                    $ttl,
943
+                    !\OC::$CLI
944
+                );
945
+            }
946
+            return new NoopLockingProvider();
947
+        });
948
+
949
+        $this->registerService(ILockManager::class, function (Server $c): LockManager {
950
+            return new LockManager();
951
+        });
952
+
953
+        $this->registerAlias(ILockdownManager::class, 'LockdownManager');
954
+        $this->registerService(SetupManager::class, function ($c) {
955
+            // create the setupmanager through the mount manager to resolve the cyclic dependency
956
+            return $c->get(\OC\Files\Mount\Manager::class)->getSetupManager();
957
+        });
958
+        $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
959
+
960
+        $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
961
+            return new \OC\Files\Type\Detection(
962
+                $c->get(IURLGenerator::class),
963
+                $c->get(LoggerInterface::class),
964
+                \OC::$configDir,
965
+                \OC::$SERVERROOT . '/resources/config/'
966
+            );
967
+        });
968
+
969
+        $this->registerAlias(IMimeTypeLoader::class, Loader::class);
970
+        $this->registerService(BundleFetcher::class, function () {
971
+            return new BundleFetcher($this->getL10N('lib'));
972
+        });
973
+        $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
974
+
975
+        $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
976
+            $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
977
+            $manager->registerCapability(function () use ($c) {
978
+                return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
979
+            });
980
+            $manager->registerCapability(function () use ($c) {
981
+                return $c->get(\OC\Security\Bruteforce\Capabilities::class);
982
+            });
983
+            return $manager;
984
+        });
985
+
986
+        $this->registerService(ICommentsManager::class, function (Server $c) {
987
+            $config = $c->get(\OCP\IConfig::class);
988
+            $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
989
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
990
+            $factory = new $factoryClass($this);
991
+            $manager = $factory->getManager();
992
+
993
+            $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
994
+                $manager = $c->get(IUserManager::class);
995
+                $userDisplayName = $manager->getDisplayName($id);
996
+                if ($userDisplayName === null) {
997
+                    $l = $c->get(IFactory::class)->get('core');
998
+                    return $l->t('Unknown account');
999
+                }
1000
+                return $userDisplayName;
1001
+            });
1002
+
1003
+            return $manager;
1004
+        });
1005
+
1006
+        $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
1007
+        $this->registerService('ThemingDefaults', function (Server $c) {
1008
+            try {
1009
+                $classExists = class_exists('OCA\Theming\ThemingDefaults');
1010
+            } catch (\OCP\AutoloadNotAllowedException $e) {
1011
+                // App disabled or in maintenance mode
1012
+                $classExists = false;
1013
+            }
1014
+
1015
+            if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
1016
+                $backgroundService = new BackgroundService(
1017
+                    $c->get(IRootFolder::class),
1018
+                    $c->get(IAppDataFactory::class)->get('theming'),
1019
+                    $c->get(IAppConfig::class),
1020
+                    $c->get(\OCP\IConfig::class),
1021
+                    $c->get(ISession::class)->get('user_id'),
1022
+                );
1023
+                $imageManager = new ImageManager(
1024
+                    $c->get(\OCP\IConfig::class),
1025
+                    $c->get(IAppDataFactory::class)->get('theming'),
1026
+                    $c->get(IURLGenerator::class),
1027
+                    $c->get(ICacheFactory::class),
1028
+                    $c->get(LoggerInterface::class),
1029
+                    $c->get(ITempManager::class),
1030
+                    $backgroundService,
1031
+                );
1032
+                return new ThemingDefaults(
1033
+                    $c->get(\OCP\IConfig::class),
1034
+                    new AppConfig(
1035
+                        $c->get(\OCP\IConfig::class),
1036
+                        $c->get(\OCP\IAppConfig::class),
1037
+                        'theming',
1038
+                    ),
1039
+                    $c->get(IFactory::class)->get('theming'),
1040
+                    $c->get(IUserSession::class),
1041
+                    $c->get(IURLGenerator::class),
1042
+                    $c->get(ICacheFactory::class),
1043
+                    new Util(
1044
+                        $c->get(ServerVersion::class),
1045
+                        $c->get(\OCP\IConfig::class),
1046
+                        $this->get(IAppManager::class),
1047
+                        $c->get(IAppDataFactory::class)->get('theming'),
1048
+                        $imageManager,
1049
+                    ),
1050
+                    $imageManager,
1051
+                    $c->get(IAppManager::class),
1052
+                    $c->get(INavigationManager::class),
1053
+                    $backgroundService,
1054
+                );
1055
+            }
1056
+            return new \OC_Defaults();
1057
+        });
1058
+        $this->registerService(JSCombiner::class, function (Server $c) {
1059
+            return new JSCombiner(
1060
+                $c->getAppDataDir('js'),
1061
+                $c->get(IURLGenerator::class),
1062
+                $this->get(ICacheFactory::class),
1063
+                $c->get(\OCP\IConfig::class),
1064
+                $c->get(LoggerInterface::class)
1065
+            );
1066
+        });
1067
+        $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
1068
+
1069
+        $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
1070
+            // FIXME: Instantiated here due to cyclic dependency
1071
+            $request = new Request(
1072
+                [
1073
+                    'get' => $_GET,
1074
+                    'post' => $_POST,
1075
+                    'files' => $_FILES,
1076
+                    'server' => $_SERVER,
1077
+                    'env' => $_ENV,
1078
+                    'cookies' => $_COOKIE,
1079
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
1080
+                        ? $_SERVER['REQUEST_METHOD']
1081
+                        : null,
1082
+                ],
1083
+                $c->get(IRequestId::class),
1084
+                $c->get(\OCP\IConfig::class)
1085
+            );
1086
+
1087
+            return new CryptoWrapper(
1088
+                $c->get(ICrypto::class),
1089
+                $c->get(ISecureRandom::class),
1090
+                $request
1091
+            );
1092
+        });
1093
+        $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
1094
+            return new SessionStorage($c->get(ISession::class));
1095
+        });
1096
+        $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
1097
+
1098
+        $this->registerService(IProviderFactory::class, function (ContainerInterface $c) {
1099
+            $config = $c->get(\OCP\IConfig::class);
1100
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
1101
+            /** @var \OCP\Share\IProviderFactory $factory */
1102
+            return $c->get($factoryClass);
1103
+        });
1104
+
1105
+        $this->registerAlias(\OCP\Share\IManager::class, \OC\Share20\Manager::class);
1106
+
1107
+        $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
1108
+            $instance = new Collaboration\Collaborators\Search($c);
1109
+
1110
+            // register default plugins
1111
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
1112
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
1113
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
1114
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
1115
+            $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
1116
+
1117
+            return $instance;
1118
+        });
1119
+        $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
1120
+
1121
+        $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
1122
+
1123
+        $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
1124
+        $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
1125
+
1126
+        $this->registerAlias(IReferenceManager::class, ReferenceManager::class);
1127
+        $this->registerAlias(ITeamManager::class, TeamManager::class);
1128
+
1129
+        $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
1130
+        $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
1131
+        $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
1132
+            return new \OC\Files\AppData\Factory(
1133
+                $c->get(IRootFolder::class),
1134
+                $c->get(SystemConfig::class)
1135
+            );
1136
+        });
1137
+
1138
+        $this->registerService('LockdownManager', function (ContainerInterface $c) {
1139
+            return new LockdownManager(function () use ($c) {
1140
+                return $c->get(ISession::class);
1141
+            });
1142
+        });
1143
+
1144
+        $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
1145
+            return new DiscoveryService(
1146
+                $c->get(ICacheFactory::class),
1147
+                $c->get(IClientService::class)
1148
+            );
1149
+        });
1150
+        $this->registerAlias(IOCMDiscoveryService::class, OCMDiscoveryService::class);
1151
+
1152
+        $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
1153
+            return new CloudIdManager(
1154
+                $c->get(ICacheFactory::class),
1155
+                $c->get(IEventDispatcher::class),
1156
+                $c->get(\OCP\Contacts\IManager::class),
1157
+                $c->get(IURLGenerator::class),
1158
+                $c->get(IUserManager::class),
1159
+            );
1160
+        });
1161 1161
 
1162
-		$this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1163
-		$this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1164
-		$this->registerService(ICloudFederationFactory::class, function (Server $c) {
1165
-			return new CloudFederationFactory();
1166
-		});
1162
+        $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
1163
+        $this->registerAlias(ICloudFederationProviderManager::class, CloudFederationProviderManager::class);
1164
+        $this->registerService(ICloudFederationFactory::class, function (Server $c) {
1165
+            return new CloudFederationFactory();
1166
+        });
1167 1167
 
1168
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1168
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
1169 1169
 
1170
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1171
-		$this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1170
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
1171
+        $this->registerAlias(\Psr\Clock\ClockInterface::class, \OCP\AppFramework\Utility\ITimeFactory::class);
1172 1172
 
1173
-		$this->registerService(Defaults::class, function (Server $c) {
1174
-			return new Defaults(
1175
-				$c->get('ThemingDefaults')
1176
-			);
1177
-		});
1173
+        $this->registerService(Defaults::class, function (Server $c) {
1174
+            return new Defaults(
1175
+                $c->get('ThemingDefaults')
1176
+            );
1177
+        });
1178 1178
 
1179
-		$this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1180
-			return $c->get(\OCP\IUserSession::class)->getSession();
1181
-		}, false);
1179
+        $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
1180
+            return $c->get(\OCP\IUserSession::class)->getSession();
1181
+        }, false);
1182 1182
 
1183
-		$this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1184
-			return new ShareHelper(
1185
-				$c->get(\OCP\Share\IManager::class)
1186
-			);
1187
-		});
1183
+        $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
1184
+            return new ShareHelper(
1185
+                $c->get(\OCP\Share\IManager::class)
1186
+            );
1187
+        });
1188 1188
 
1189
-		$this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1190
-			return new ApiFactory($c->get(IClientService::class));
1191
-		});
1189
+        $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
1190
+            return new ApiFactory($c->get(IClientService::class));
1191
+        });
1192 1192
 
1193
-		$this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1194
-			$memcacheFactory = $c->get(ICacheFactory::class);
1195
-			return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1196
-		});
1193
+        $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
1194
+            $memcacheFactory = $c->get(ICacheFactory::class);
1195
+            return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
1196
+        });
1197 1197
 
1198
-		$this->registerAlias(IContactsStore::class, ContactsStore::class);
1199
-		$this->registerAlias(IAccountManager::class, AccountManager::class);
1198
+        $this->registerAlias(IContactsStore::class, ContactsStore::class);
1199
+        $this->registerAlias(IAccountManager::class, AccountManager::class);
1200 1200
 
1201
-		$this->registerAlias(IStorageFactory::class, StorageFactory::class);
1201
+        $this->registerAlias(IStorageFactory::class, StorageFactory::class);
1202 1202
 
1203
-		$this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1203
+        $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
1204 1204
 
1205
-		$this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1206
-		$this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1205
+        $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
1206
+        $this->registerAlias(IFilesMetadataManager::class, FilesMetadataManager::class);
1207 1207
 
1208
-		$this->registerAlias(ISubAdmin::class, SubAdmin::class);
1208
+        $this->registerAlias(ISubAdmin::class, SubAdmin::class);
1209 1209
 
1210
-		$this->registerAlias(IInitialStateService::class, InitialStateService::class);
1210
+        $this->registerAlias(IInitialStateService::class, InitialStateService::class);
1211 1211
 
1212
-		$this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1212
+        $this->registerAlias(\OCP\IEmojiHelper::class, \OC\EmojiHelper::class);
1213 1213
 
1214
-		$this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1214
+        $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
1215 1215
 
1216
-		$this->registerAlias(IBroker::class, Broker::class);
1216
+        $this->registerAlias(IBroker::class, Broker::class);
1217 1217
 
1218
-		$this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1218
+        $this->registerAlias(\OCP\Files\AppData\IAppDataFactory::class, \OC\Files\AppData\Factory::class);
1219 1219
 
1220
-		$this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1220
+        $this->registerAlias(\OCP\Files\IFilenameValidator::class, \OC\Files\FilenameValidator::class);
1221 1221
 
1222
-		$this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1222
+        $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
1223 1223
 
1224
-		$this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1224
+        $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
1225 1225
 
1226
-		$this->registerAlias(ITranslationManager::class, TranslationManager::class);
1226
+        $this->registerAlias(ITranslationManager::class, TranslationManager::class);
1227 1227
 
1228
-		$this->registerAlias(IConversionManager::class, ConversionManager::class);
1228
+        $this->registerAlias(IConversionManager::class, ConversionManager::class);
1229 1229
 
1230
-		$this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1230
+        $this->registerAlias(ISpeechToTextManager::class, SpeechToTextManager::class);
1231 1231
 
1232
-		$this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1232
+        $this->registerAlias(IEventSourceFactory::class, EventSourceFactory::class);
1233 1233
 
1234
-		$this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1234
+        $this->registerAlias(\OCP\TextProcessing\IManager::class, \OC\TextProcessing\Manager::class);
1235 1235
 
1236
-		$this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1236
+        $this->registerAlias(\OCP\TextToImage\IManager::class, \OC\TextToImage\Manager::class);
1237 1237
 
1238
-		$this->registerAlias(ILimiter::class, Limiter::class);
1238
+        $this->registerAlias(ILimiter::class, Limiter::class);
1239 1239
 
1240
-		$this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1240
+        $this->registerAlias(IPhoneNumberUtil::class, PhoneNumberUtil::class);
1241 1241
 
1242
-		// there is no reason for having OCMProvider as a Service
1243
-		$this->registerDeprecatedAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1244
-		$this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1242
+        // there is no reason for having OCMProvider as a Service
1243
+        $this->registerDeprecatedAlias(ICapabilityAwareOCMProvider::class, OCMProvider::class);
1244
+        $this->registerDeprecatedAlias(IOCMProvider::class, OCMProvider::class);
1245 1245
 
1246
-		$this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1246
+        $this->registerAlias(ISetupCheckManager::class, SetupCheckManager::class);
1247 1247
 
1248
-		$this->registerAlias(IProfileManager::class, ProfileManager::class);
1248
+        $this->registerAlias(IProfileManager::class, ProfileManager::class);
1249 1249
 
1250
-		$this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1250
+        $this->registerAlias(IAvailabilityCoordinator::class, AvailabilityCoordinator::class);
1251 1251
 
1252
-		$this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1252
+        $this->registerAlias(IDeclarativeManager::class, DeclarativeManager::class);
1253 1253
 
1254
-		$this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1254
+        $this->registerAlias(\OCP\TaskProcessing\IManager::class, \OC\TaskProcessing\Manager::class);
1255 1255
 
1256
-		$this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1256
+        $this->registerAlias(IRemoteAddress::class, RemoteAddress::class);
1257 1257
 
1258
-		$this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1258
+        $this->registerAlias(\OCP\Security\Ip\IFactory::class, \OC\Security\Ip\Factory::class);
1259 1259
 
1260
-		$this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1260
+        $this->registerAlias(IRichTextFormatter::class, \OC\RichObjectStrings\RichTextFormatter::class);
1261 1261
 
1262
-		$this->registerAlias(ISignatureManager::class, SignatureManager::class);
1262
+        $this->registerAlias(ISignatureManager::class, SignatureManager::class);
1263 1263
 
1264
-		$this->registerAlias(IGenerator::class, Generator::class);
1265
-		$this->registerAlias(IDecoder::class, Decoder::class);
1264
+        $this->registerAlias(IGenerator::class, Generator::class);
1265
+        $this->registerAlias(IDecoder::class, Decoder::class);
1266 1266
 
1267
-		$this->connectDispatcher();
1268
-	}
1267
+        $this->connectDispatcher();
1268
+    }
1269 1269
 
1270
-	public function boot() {
1271
-		/** @var HookConnector $hookConnector */
1272
-		$hookConnector = $this->get(HookConnector::class);
1273
-		$hookConnector->viewToNode();
1274
-	}
1275
-
1276
-	private function connectDispatcher(): void {
1277
-		/** @var IEventDispatcher $eventDispatcher */
1278
-		$eventDispatcher = $this->get(IEventDispatcher::class);
1279
-		$eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1280
-		$eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1281
-		$eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1282
-		$eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1283
-
1284
-		FilesMetadataManager::loadListeners($eventDispatcher);
1285
-		GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1286
-	}
1287
-
1288
-	/**
1289
-	 * @return \OCP\Contacts\IManager
1290
-	 * @deprecated 20.0.0
1291
-	 */
1292
-	public function getContactsManager() {
1293
-		return $this->get(\OCP\Contacts\IManager::class);
1294
-	}
1295
-
1296
-	/**
1297
-	 * @return \OC\Encryption\Manager
1298
-	 * @deprecated 20.0.0
1299
-	 */
1300
-	public function getEncryptionManager() {
1301
-		return $this->get(\OCP\Encryption\IManager::class);
1302
-	}
1303
-
1304
-	/**
1305
-	 * @return \OC\Encryption\File
1306
-	 * @deprecated 20.0.0
1307
-	 */
1308
-	public function getEncryptionFilesHelper() {
1309
-		return $this->get(IFile::class);
1310
-	}
1311
-
1312
-	/**
1313
-	 * The current request object holding all information about the request
1314
-	 * currently being processed is returned from this method.
1315
-	 * In case the current execution was not initiated by a web request null is returned
1316
-	 *
1317
-	 * @return \OCP\IRequest
1318
-	 * @deprecated 20.0.0
1319
-	 */
1320
-	public function getRequest() {
1321
-		return $this->get(IRequest::class);
1322
-	}
1323
-
1324
-	/**
1325
-	 * Returns the root folder of ownCloud's data directory
1326
-	 *
1327
-	 * @return IRootFolder
1328
-	 * @deprecated 20.0.0
1329
-	 */
1330
-	public function getRootFolder() {
1331
-		return $this->get(IRootFolder::class);
1332
-	}
1333
-
1334
-	/**
1335
-	 * Returns the root folder of ownCloud's data directory
1336
-	 * This is the lazy variant so this gets only initialized once it
1337
-	 * is actually used.
1338
-	 *
1339
-	 * @return IRootFolder
1340
-	 * @deprecated 20.0.0
1341
-	 */
1342
-	public function getLazyRootFolder() {
1343
-		return $this->get(IRootFolder::class);
1344
-	}
1345
-
1346
-	/**
1347
-	 * Returns a view to ownCloud's files folder
1348
-	 *
1349
-	 * @param string $userId user ID
1350
-	 * @return \OCP\Files\Folder|null
1351
-	 * @deprecated 20.0.0
1352
-	 */
1353
-	public function getUserFolder($userId = null) {
1354
-		if ($userId === null) {
1355
-			$user = $this->get(IUserSession::class)->getUser();
1356
-			if (!$user) {
1357
-				return null;
1358
-			}
1359
-			$userId = $user->getUID();
1360
-		}
1361
-		$root = $this->get(IRootFolder::class);
1362
-		return $root->getUserFolder($userId);
1363
-	}
1364
-
1365
-	/**
1366
-	 * @return \OC\User\Manager
1367
-	 * @deprecated 20.0.0
1368
-	 */
1369
-	public function getUserManager() {
1370
-		return $this->get(IUserManager::class);
1371
-	}
1372
-
1373
-	/**
1374
-	 * @return \OC\Group\Manager
1375
-	 * @deprecated 20.0.0
1376
-	 */
1377
-	public function getGroupManager() {
1378
-		return $this->get(IGroupManager::class);
1379
-	}
1380
-
1381
-	/**
1382
-	 * @return \OC\User\Session
1383
-	 * @deprecated 20.0.0
1384
-	 */
1385
-	public function getUserSession() {
1386
-		return $this->get(IUserSession::class);
1387
-	}
1388
-
1389
-	/**
1390
-	 * @return \OCP\ISession
1391
-	 * @deprecated 20.0.0
1392
-	 */
1393
-	public function getSession() {
1394
-		return $this->get(Session::class)->getSession();
1395
-	}
1396
-
1397
-	/**
1398
-	 * @param \OCP\ISession $session
1399
-	 * @return void
1400
-	 */
1401
-	public function setSession(\OCP\ISession $session) {
1402
-		$this->get(SessionStorage::class)->setSession($session);
1403
-		$this->get(Session::class)->setSession($session);
1404
-		$this->get(Store::class)->setSession($session);
1405
-	}
1406
-
1407
-	/**
1408
-	 * @return \OCP\IConfig
1409
-	 * @deprecated 20.0.0
1410
-	 */
1411
-	public function getConfig() {
1412
-		return $this->get(AllConfig::class);
1413
-	}
1414
-
1415
-	/**
1416
-	 * @return \OC\SystemConfig
1417
-	 * @deprecated 20.0.0
1418
-	 */
1419
-	public function getSystemConfig() {
1420
-		return $this->get(SystemConfig::class);
1421
-	}
1422
-
1423
-	/**
1424
-	 * @return IFactory
1425
-	 * @deprecated 20.0.0
1426
-	 */
1427
-	public function getL10NFactory() {
1428
-		return $this->get(IFactory::class);
1429
-	}
1430
-
1431
-	/**
1432
-	 * get an L10N instance
1433
-	 *
1434
-	 * @param string $app appid
1435
-	 * @param string $lang
1436
-	 * @return IL10N
1437
-	 * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1438
-	 */
1439
-	public function getL10N($app, $lang = null) {
1440
-		return $this->get(IFactory::class)->get($app, $lang);
1441
-	}
1442
-
1443
-	/**
1444
-	 * @return IURLGenerator
1445
-	 * @deprecated 20.0.0
1446
-	 */
1447
-	public function getURLGenerator() {
1448
-		return $this->get(IURLGenerator::class);
1449
-	}
1450
-
1451
-	/**
1452
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1453
-	 * getMemCacheFactory() instead.
1454
-	 *
1455
-	 * @return ICache
1456
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1457
-	 */
1458
-	public function getCache() {
1459
-		return $this->get(ICache::class);
1460
-	}
1461
-
1462
-	/**
1463
-	 * Returns an \OCP\CacheFactory instance
1464
-	 *
1465
-	 * @return \OCP\ICacheFactory
1466
-	 * @deprecated 20.0.0
1467
-	 */
1468
-	public function getMemCacheFactory() {
1469
-		return $this->get(ICacheFactory::class);
1470
-	}
1471
-
1472
-	/**
1473
-	 * Returns the current session
1474
-	 *
1475
-	 * @return \OCP\IDBConnection
1476
-	 * @deprecated 20.0.0
1477
-	 */
1478
-	public function getDatabaseConnection() {
1479
-		return $this->get(IDBConnection::class);
1480
-	}
1481
-
1482
-	/**
1483
-	 * Returns the activity manager
1484
-	 *
1485
-	 * @return \OCP\Activity\IManager
1486
-	 * @deprecated 20.0.0
1487
-	 */
1488
-	public function getActivityManager() {
1489
-		return $this->get(\OCP\Activity\IManager::class);
1490
-	}
1491
-
1492
-	/**
1493
-	 * Returns an job list for controlling background jobs
1494
-	 *
1495
-	 * @return IJobList
1496
-	 * @deprecated 20.0.0
1497
-	 */
1498
-	public function getJobList() {
1499
-		return $this->get(IJobList::class);
1500
-	}
1501
-
1502
-	/**
1503
-	 * Returns a SecureRandom instance
1504
-	 *
1505
-	 * @return \OCP\Security\ISecureRandom
1506
-	 * @deprecated 20.0.0
1507
-	 */
1508
-	public function getSecureRandom() {
1509
-		return $this->get(ISecureRandom::class);
1510
-	}
1511
-
1512
-	/**
1513
-	 * Returns a Crypto instance
1514
-	 *
1515
-	 * @return ICrypto
1516
-	 * @deprecated 20.0.0
1517
-	 */
1518
-	public function getCrypto() {
1519
-		return $this->get(ICrypto::class);
1520
-	}
1521
-
1522
-	/**
1523
-	 * Returns a Hasher instance
1524
-	 *
1525
-	 * @return IHasher
1526
-	 * @deprecated 20.0.0
1527
-	 */
1528
-	public function getHasher() {
1529
-		return $this->get(IHasher::class);
1530
-	}
1531
-
1532
-	/**
1533
-	 * Get the certificate manager
1534
-	 *
1535
-	 * @return \OCP\ICertificateManager
1536
-	 */
1537
-	public function getCertificateManager() {
1538
-		return $this->get(ICertificateManager::class);
1539
-	}
1540
-
1541
-	/**
1542
-	 * Get the manager for temporary files and folders
1543
-	 *
1544
-	 * @return \OCP\ITempManager
1545
-	 * @deprecated 20.0.0
1546
-	 */
1547
-	public function getTempManager() {
1548
-		return $this->get(ITempManager::class);
1549
-	}
1550
-
1551
-	/**
1552
-	 * Get the app manager
1553
-	 *
1554
-	 * @return \OCP\App\IAppManager
1555
-	 * @deprecated 20.0.0
1556
-	 */
1557
-	public function getAppManager() {
1558
-		return $this->get(IAppManager::class);
1559
-	}
1560
-
1561
-	/**
1562
-	 * Creates a new mailer
1563
-	 *
1564
-	 * @return IMailer
1565
-	 * @deprecated 20.0.0
1566
-	 */
1567
-	public function getMailer() {
1568
-		return $this->get(IMailer::class);
1569
-	}
1570
-
1571
-	/**
1572
-	 * Get the webroot
1573
-	 *
1574
-	 * @return string
1575
-	 * @deprecated 20.0.0
1576
-	 */
1577
-	public function getWebRoot() {
1578
-		return $this->webRoot;
1579
-	}
1580
-
1581
-	/**
1582
-	 * Get the locking provider
1583
-	 *
1584
-	 * @return ILockingProvider
1585
-	 * @since 8.1.0
1586
-	 * @deprecated 20.0.0
1587
-	 */
1588
-	public function getLockingProvider() {
1589
-		return $this->get(ILockingProvider::class);
1590
-	}
1591
-
1592
-	/**
1593
-	 * Get the MimeTypeDetector
1594
-	 *
1595
-	 * @return IMimeTypeDetector
1596
-	 * @deprecated 20.0.0
1597
-	 */
1598
-	public function getMimeTypeDetector() {
1599
-		return $this->get(IMimeTypeDetector::class);
1600
-	}
1601
-
1602
-	/**
1603
-	 * Get the MimeTypeLoader
1604
-	 *
1605
-	 * @return IMimeTypeLoader
1606
-	 * @deprecated 20.0.0
1607
-	 */
1608
-	public function getMimeTypeLoader() {
1609
-		return $this->get(IMimeTypeLoader::class);
1610
-	}
1611
-
1612
-	/**
1613
-	 * Get the Notification Manager
1614
-	 *
1615
-	 * @return \OCP\Notification\IManager
1616
-	 * @since 8.2.0
1617
-	 * @deprecated 20.0.0
1618
-	 */
1619
-	public function getNotificationManager() {
1620
-		return $this->get(\OCP\Notification\IManager::class);
1621
-	}
1622
-
1623
-	/**
1624
-	 * @return \OCA\Theming\ThemingDefaults
1625
-	 * @deprecated 20.0.0
1626
-	 */
1627
-	public function getThemingDefaults() {
1628
-		return $this->get('ThemingDefaults');
1629
-	}
1630
-
1631
-	/**
1632
-	 * @return \OC\IntegrityCheck\Checker
1633
-	 * @deprecated 20.0.0
1634
-	 */
1635
-	public function getIntegrityCodeChecker() {
1636
-		return $this->get('IntegrityCodeChecker');
1637
-	}
1638
-
1639
-	/**
1640
-	 * @return CsrfTokenManager
1641
-	 * @deprecated 20.0.0
1642
-	 */
1643
-	public function getCsrfTokenManager() {
1644
-		return $this->get(CsrfTokenManager::class);
1645
-	}
1646
-
1647
-	/**
1648
-	 * @return ContentSecurityPolicyNonceManager
1649
-	 * @deprecated 20.0.0
1650
-	 */
1651
-	public function getContentSecurityPolicyNonceManager() {
1652
-		return $this->get(ContentSecurityPolicyNonceManager::class);
1653
-	}
1654
-
1655
-	/**
1656
-	 * @return \OCP\Settings\IManager
1657
-	 * @deprecated 20.0.0
1658
-	 */
1659
-	public function getSettingsManager() {
1660
-		return $this->get(\OC\Settings\Manager::class);
1661
-	}
1662
-
1663
-	/**
1664
-	 * @return \OCP\Files\IAppData
1665
-	 * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1666
-	 */
1667
-	public function getAppDataDir($app) {
1668
-		$factory = $this->get(\OC\Files\AppData\Factory::class);
1669
-		return $factory->get($app);
1670
-	}
1671
-
1672
-	/**
1673
-	 * @return \OCP\Federation\ICloudIdManager
1674
-	 * @deprecated 20.0.0
1675
-	 */
1676
-	public function getCloudIdManager() {
1677
-		return $this->get(ICloudIdManager::class);
1678
-	}
1270
+    public function boot() {
1271
+        /** @var HookConnector $hookConnector */
1272
+        $hookConnector = $this->get(HookConnector::class);
1273
+        $hookConnector->viewToNode();
1274
+    }
1275
+
1276
+    private function connectDispatcher(): void {
1277
+        /** @var IEventDispatcher $eventDispatcher */
1278
+        $eventDispatcher = $this->get(IEventDispatcher::class);
1279
+        $eventDispatcher->addServiceListener(LoginFailed::class, LoginFailedListener::class);
1280
+        $eventDispatcher->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
1281
+        $eventDispatcher->addServiceListener(UserChangedEvent::class, UserChangedListener::class);
1282
+        $eventDispatcher->addServiceListener(BeforeUserDeletedEvent::class, BeforeUserDeletedListener::class);
1283
+
1284
+        FilesMetadataManager::loadListeners($eventDispatcher);
1285
+        GenerateBlurhashMetadata::loadListeners($eventDispatcher);
1286
+    }
1287
+
1288
+    /**
1289
+     * @return \OCP\Contacts\IManager
1290
+     * @deprecated 20.0.0
1291
+     */
1292
+    public function getContactsManager() {
1293
+        return $this->get(\OCP\Contacts\IManager::class);
1294
+    }
1295
+
1296
+    /**
1297
+     * @return \OC\Encryption\Manager
1298
+     * @deprecated 20.0.0
1299
+     */
1300
+    public function getEncryptionManager() {
1301
+        return $this->get(\OCP\Encryption\IManager::class);
1302
+    }
1303
+
1304
+    /**
1305
+     * @return \OC\Encryption\File
1306
+     * @deprecated 20.0.0
1307
+     */
1308
+    public function getEncryptionFilesHelper() {
1309
+        return $this->get(IFile::class);
1310
+    }
1311
+
1312
+    /**
1313
+     * The current request object holding all information about the request
1314
+     * currently being processed is returned from this method.
1315
+     * In case the current execution was not initiated by a web request null is returned
1316
+     *
1317
+     * @return \OCP\IRequest
1318
+     * @deprecated 20.0.0
1319
+     */
1320
+    public function getRequest() {
1321
+        return $this->get(IRequest::class);
1322
+    }
1323
+
1324
+    /**
1325
+     * Returns the root folder of ownCloud's data directory
1326
+     *
1327
+     * @return IRootFolder
1328
+     * @deprecated 20.0.0
1329
+     */
1330
+    public function getRootFolder() {
1331
+        return $this->get(IRootFolder::class);
1332
+    }
1333
+
1334
+    /**
1335
+     * Returns the root folder of ownCloud's data directory
1336
+     * This is the lazy variant so this gets only initialized once it
1337
+     * is actually used.
1338
+     *
1339
+     * @return IRootFolder
1340
+     * @deprecated 20.0.0
1341
+     */
1342
+    public function getLazyRootFolder() {
1343
+        return $this->get(IRootFolder::class);
1344
+    }
1345
+
1346
+    /**
1347
+     * Returns a view to ownCloud's files folder
1348
+     *
1349
+     * @param string $userId user ID
1350
+     * @return \OCP\Files\Folder|null
1351
+     * @deprecated 20.0.0
1352
+     */
1353
+    public function getUserFolder($userId = null) {
1354
+        if ($userId === null) {
1355
+            $user = $this->get(IUserSession::class)->getUser();
1356
+            if (!$user) {
1357
+                return null;
1358
+            }
1359
+            $userId = $user->getUID();
1360
+        }
1361
+        $root = $this->get(IRootFolder::class);
1362
+        return $root->getUserFolder($userId);
1363
+    }
1364
+
1365
+    /**
1366
+     * @return \OC\User\Manager
1367
+     * @deprecated 20.0.0
1368
+     */
1369
+    public function getUserManager() {
1370
+        return $this->get(IUserManager::class);
1371
+    }
1372
+
1373
+    /**
1374
+     * @return \OC\Group\Manager
1375
+     * @deprecated 20.0.0
1376
+     */
1377
+    public function getGroupManager() {
1378
+        return $this->get(IGroupManager::class);
1379
+    }
1380
+
1381
+    /**
1382
+     * @return \OC\User\Session
1383
+     * @deprecated 20.0.0
1384
+     */
1385
+    public function getUserSession() {
1386
+        return $this->get(IUserSession::class);
1387
+    }
1388
+
1389
+    /**
1390
+     * @return \OCP\ISession
1391
+     * @deprecated 20.0.0
1392
+     */
1393
+    public function getSession() {
1394
+        return $this->get(Session::class)->getSession();
1395
+    }
1396
+
1397
+    /**
1398
+     * @param \OCP\ISession $session
1399
+     * @return void
1400
+     */
1401
+    public function setSession(\OCP\ISession $session) {
1402
+        $this->get(SessionStorage::class)->setSession($session);
1403
+        $this->get(Session::class)->setSession($session);
1404
+        $this->get(Store::class)->setSession($session);
1405
+    }
1406
+
1407
+    /**
1408
+     * @return \OCP\IConfig
1409
+     * @deprecated 20.0.0
1410
+     */
1411
+    public function getConfig() {
1412
+        return $this->get(AllConfig::class);
1413
+    }
1414
+
1415
+    /**
1416
+     * @return \OC\SystemConfig
1417
+     * @deprecated 20.0.0
1418
+     */
1419
+    public function getSystemConfig() {
1420
+        return $this->get(SystemConfig::class);
1421
+    }
1422
+
1423
+    /**
1424
+     * @return IFactory
1425
+     * @deprecated 20.0.0
1426
+     */
1427
+    public function getL10NFactory() {
1428
+        return $this->get(IFactory::class);
1429
+    }
1430
+
1431
+    /**
1432
+     * get an L10N instance
1433
+     *
1434
+     * @param string $app appid
1435
+     * @param string $lang
1436
+     * @return IL10N
1437
+     * @deprecated 20.0.0 use DI of {@see IL10N} or {@see IFactory} instead, or {@see \OCP\Util::getL10N()} as a last resort
1438
+     */
1439
+    public function getL10N($app, $lang = null) {
1440
+        return $this->get(IFactory::class)->get($app, $lang);
1441
+    }
1442
+
1443
+    /**
1444
+     * @return IURLGenerator
1445
+     * @deprecated 20.0.0
1446
+     */
1447
+    public function getURLGenerator() {
1448
+        return $this->get(IURLGenerator::class);
1449
+    }
1450
+
1451
+    /**
1452
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1453
+     * getMemCacheFactory() instead.
1454
+     *
1455
+     * @return ICache
1456
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1457
+     */
1458
+    public function getCache() {
1459
+        return $this->get(ICache::class);
1460
+    }
1461
+
1462
+    /**
1463
+     * Returns an \OCP\CacheFactory instance
1464
+     *
1465
+     * @return \OCP\ICacheFactory
1466
+     * @deprecated 20.0.0
1467
+     */
1468
+    public function getMemCacheFactory() {
1469
+        return $this->get(ICacheFactory::class);
1470
+    }
1471
+
1472
+    /**
1473
+     * Returns the current session
1474
+     *
1475
+     * @return \OCP\IDBConnection
1476
+     * @deprecated 20.0.0
1477
+     */
1478
+    public function getDatabaseConnection() {
1479
+        return $this->get(IDBConnection::class);
1480
+    }
1481
+
1482
+    /**
1483
+     * Returns the activity manager
1484
+     *
1485
+     * @return \OCP\Activity\IManager
1486
+     * @deprecated 20.0.0
1487
+     */
1488
+    public function getActivityManager() {
1489
+        return $this->get(\OCP\Activity\IManager::class);
1490
+    }
1491
+
1492
+    /**
1493
+     * Returns an job list for controlling background jobs
1494
+     *
1495
+     * @return IJobList
1496
+     * @deprecated 20.0.0
1497
+     */
1498
+    public function getJobList() {
1499
+        return $this->get(IJobList::class);
1500
+    }
1501
+
1502
+    /**
1503
+     * Returns a SecureRandom instance
1504
+     *
1505
+     * @return \OCP\Security\ISecureRandom
1506
+     * @deprecated 20.0.0
1507
+     */
1508
+    public function getSecureRandom() {
1509
+        return $this->get(ISecureRandom::class);
1510
+    }
1511
+
1512
+    /**
1513
+     * Returns a Crypto instance
1514
+     *
1515
+     * @return ICrypto
1516
+     * @deprecated 20.0.0
1517
+     */
1518
+    public function getCrypto() {
1519
+        return $this->get(ICrypto::class);
1520
+    }
1521
+
1522
+    /**
1523
+     * Returns a Hasher instance
1524
+     *
1525
+     * @return IHasher
1526
+     * @deprecated 20.0.0
1527
+     */
1528
+    public function getHasher() {
1529
+        return $this->get(IHasher::class);
1530
+    }
1531
+
1532
+    /**
1533
+     * Get the certificate manager
1534
+     *
1535
+     * @return \OCP\ICertificateManager
1536
+     */
1537
+    public function getCertificateManager() {
1538
+        return $this->get(ICertificateManager::class);
1539
+    }
1540
+
1541
+    /**
1542
+     * Get the manager for temporary files and folders
1543
+     *
1544
+     * @return \OCP\ITempManager
1545
+     * @deprecated 20.0.0
1546
+     */
1547
+    public function getTempManager() {
1548
+        return $this->get(ITempManager::class);
1549
+    }
1550
+
1551
+    /**
1552
+     * Get the app manager
1553
+     *
1554
+     * @return \OCP\App\IAppManager
1555
+     * @deprecated 20.0.0
1556
+     */
1557
+    public function getAppManager() {
1558
+        return $this->get(IAppManager::class);
1559
+    }
1560
+
1561
+    /**
1562
+     * Creates a new mailer
1563
+     *
1564
+     * @return IMailer
1565
+     * @deprecated 20.0.0
1566
+     */
1567
+    public function getMailer() {
1568
+        return $this->get(IMailer::class);
1569
+    }
1570
+
1571
+    /**
1572
+     * Get the webroot
1573
+     *
1574
+     * @return string
1575
+     * @deprecated 20.0.0
1576
+     */
1577
+    public function getWebRoot() {
1578
+        return $this->webRoot;
1579
+    }
1580
+
1581
+    /**
1582
+     * Get the locking provider
1583
+     *
1584
+     * @return ILockingProvider
1585
+     * @since 8.1.0
1586
+     * @deprecated 20.0.0
1587
+     */
1588
+    public function getLockingProvider() {
1589
+        return $this->get(ILockingProvider::class);
1590
+    }
1591
+
1592
+    /**
1593
+     * Get the MimeTypeDetector
1594
+     *
1595
+     * @return IMimeTypeDetector
1596
+     * @deprecated 20.0.0
1597
+     */
1598
+    public function getMimeTypeDetector() {
1599
+        return $this->get(IMimeTypeDetector::class);
1600
+    }
1601
+
1602
+    /**
1603
+     * Get the MimeTypeLoader
1604
+     *
1605
+     * @return IMimeTypeLoader
1606
+     * @deprecated 20.0.0
1607
+     */
1608
+    public function getMimeTypeLoader() {
1609
+        return $this->get(IMimeTypeLoader::class);
1610
+    }
1611
+
1612
+    /**
1613
+     * Get the Notification Manager
1614
+     *
1615
+     * @return \OCP\Notification\IManager
1616
+     * @since 8.2.0
1617
+     * @deprecated 20.0.0
1618
+     */
1619
+    public function getNotificationManager() {
1620
+        return $this->get(\OCP\Notification\IManager::class);
1621
+    }
1622
+
1623
+    /**
1624
+     * @return \OCA\Theming\ThemingDefaults
1625
+     * @deprecated 20.0.0
1626
+     */
1627
+    public function getThemingDefaults() {
1628
+        return $this->get('ThemingDefaults');
1629
+    }
1630
+
1631
+    /**
1632
+     * @return \OC\IntegrityCheck\Checker
1633
+     * @deprecated 20.0.0
1634
+     */
1635
+    public function getIntegrityCodeChecker() {
1636
+        return $this->get('IntegrityCodeChecker');
1637
+    }
1638
+
1639
+    /**
1640
+     * @return CsrfTokenManager
1641
+     * @deprecated 20.0.0
1642
+     */
1643
+    public function getCsrfTokenManager() {
1644
+        return $this->get(CsrfTokenManager::class);
1645
+    }
1646
+
1647
+    /**
1648
+     * @return ContentSecurityPolicyNonceManager
1649
+     * @deprecated 20.0.0
1650
+     */
1651
+    public function getContentSecurityPolicyNonceManager() {
1652
+        return $this->get(ContentSecurityPolicyNonceManager::class);
1653
+    }
1654
+
1655
+    /**
1656
+     * @return \OCP\Settings\IManager
1657
+     * @deprecated 20.0.0
1658
+     */
1659
+    public function getSettingsManager() {
1660
+        return $this->get(\OC\Settings\Manager::class);
1661
+    }
1662
+
1663
+    /**
1664
+     * @return \OCP\Files\IAppData
1665
+     * @deprecated 20.0.0 Use get(\OCP\Files\AppData\IAppDataFactory::class)->get($app) instead
1666
+     */
1667
+    public function getAppDataDir($app) {
1668
+        $factory = $this->get(\OC\Files\AppData\Factory::class);
1669
+        return $factory->get($app);
1670
+    }
1671
+
1672
+    /**
1673
+     * @return \OCP\Federation\ICloudIdManager
1674
+     * @deprecated 20.0.0
1675
+     */
1676
+    public function getCloudIdManager() {
1677
+        return $this->get(ICloudIdManager::class);
1678
+    }
1679 1679
 }
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 2 patches
Indentation   +512 added lines, -512 removed lines patch added patch discarded remove patch
@@ -22,516 +22,516 @@
 block discarded – undo
22 22
 
23 23
 class ThemingDefaults extends \OC_Defaults {
24 24
 
25
-	private string $name;
26
-	private string $title;
27
-	private string $entity;
28
-	private string $productName;
29
-	private string $url;
30
-	private string $backgroundColor;
31
-	private string $primaryColor;
32
-	private string $docBaseUrl;
33
-
34
-	private string $iTunesAppId;
35
-	private string $iOSClientUrl;
36
-	private string $AndroidClientUrl;
37
-	private string $FDroidClientUrl;
38
-
39
-	/**
40
-	 * ThemingDefaults constructor.
41
-	 */
42
-	public function __construct(
43
-		private IConfig $config,
44
-		private IAppConfig $appConfig,
45
-		private IL10N $l,
46
-		private IUserSession $userSession,
47
-		private IURLGenerator $urlGenerator,
48
-		private ICacheFactory $cacheFactory,
49
-		private Util $util,
50
-		private ImageManager $imageManager,
51
-		private IAppManager $appManager,
52
-		private INavigationManager $navigationManager,
53
-		private BackgroundService $backgroundService,
54
-	) {
55
-		parent::__construct();
56
-
57
-		$this->name = parent::getName();
58
-		$this->title = parent::getTitle();
59
-		$this->entity = parent::getEntity();
60
-		$this->productName = parent::getProductName();
61
-		$this->url = parent::getBaseUrl();
62
-		$this->primaryColor = parent::getColorPrimary();
63
-		$this->backgroundColor = parent::getColorBackground();
64
-		$this->iTunesAppId = parent::getiTunesAppId();
65
-		$this->iOSClientUrl = parent::getiOSClientUrl();
66
-		$this->AndroidClientUrl = parent::getAndroidClientUrl();
67
-		$this->FDroidClientUrl = parent::getFDroidClientUrl();
68
-		$this->docBaseUrl = parent::getDocBaseUrl();
69
-	}
70
-
71
-	public function getName() {
72
-		return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->name));
73
-	}
74
-
75
-	public function getHTMLName() {
76
-		return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->name);
77
-	}
78
-
79
-	public function getTitle() {
80
-		return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->title));
81
-	}
82
-
83
-	public function getEntity() {
84
-		return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->entity));
85
-	}
86
-
87
-	public function getProductName() {
88
-		return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::PRODUCT_NAME, $this->productName));
89
-	}
90
-
91
-	public function getBaseUrl() {
92
-		return $this->appConfig->getAppValueString(ConfigLexicon::BASE_URL, $this->url);
93
-	}
94
-
95
-	/**
96
-	 * We pass a string and sanitizeHTML will return a string too in that case
97
-	 * @psalm-suppress InvalidReturnStatement
98
-	 * @psalm-suppress InvalidReturnType
99
-	 */
100
-	public function getSlogan(?string $lang = null): string {
101
-		return \OCP\Util::sanitizeHTML($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_SLOGAN, parent::getSlogan($lang)));
102
-	}
103
-
104
-	public function getImprintUrl(): string {
105
-		return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_IMPRINT_URL, '');
106
-	}
107
-
108
-	public function getPrivacyUrl(): string {
109
-		return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_PRIVACY_URL, '');
110
-	}
111
-
112
-	public function getDocBaseUrl(): string {
113
-		return $this->appConfig->getAppValueString(ConfigLexicon::DOC_BASE_URL, $this->docBaseUrl);
114
-	}
115
-
116
-	public function getShortFooter() {
117
-		$slogan = $this->getSlogan();
118
-		$baseUrl = $this->getBaseUrl();
119
-		$entity = $this->getEntity();
120
-		$footer = '';
121
-
122
-		if ($entity !== '') {
123
-			if ($baseUrl !== '') {
124
-				$footer = '<a href="' . $baseUrl . '" target="_blank"'
125
-					. ' rel="noreferrer noopener" class="entity-name">' . $entity . '</a>';
126
-			} else {
127
-				$footer = '<span class="entity-name">' . $entity . '</span>';
128
-			}
129
-		}
130
-		$footer .= ($slogan !== '' ? ' – ' . $slogan : '');
131
-
132
-		$links = [
133
-			[
134
-				'text' => $this->l->t('Legal notice'),
135
-				'url' => $this->getImprintUrl()
136
-			],
137
-			[
138
-				'text' => $this->l->t('Privacy policy'),
139
-				'url' => $this->getPrivacyUrl()
140
-			],
141
-		];
142
-
143
-		$navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
144
-		$guestNavigation = array_map(function ($nav) {
145
-			return [
146
-				'text' => $nav['name'],
147
-				'url' => $nav['href']
148
-			];
149
-		}, $navigation);
150
-		$links = array_merge($links, $guestNavigation);
151
-
152
-		$legalLinks = '';
153
-		$divider = '';
154
-		foreach ($links as $link) {
155
-			if ($link['url'] !== ''
156
-				&& filter_var($link['url'], FILTER_VALIDATE_URL)
157
-			) {
158
-				$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"'
159
-					. ' rel="noreferrer noopener">' . $link['text'] . '</a>';
160
-				$divider = ' · ';
161
-			}
162
-		}
163
-		if ($legalLinks !== '') {
164
-			$footer .= '<br/><span class="footer__legal-links">' . $legalLinks . '</span>';
165
-		}
166
-
167
-		return $footer;
168
-	}
169
-
170
-	/**
171
-	 * Color that is used for highlighting elements like important buttons
172
-	 * If user theming is enabled then the user defined value is returned
173
-	 */
174
-	public function getColorPrimary(): string {
175
-		$user = $this->userSession->getUser();
176
-
177
-		// admin-defined primary color
178
-		$defaultColor = $this->getDefaultColorPrimary();
179
-
180
-		if ($this->isUserThemingDisabled()) {
181
-			return $defaultColor;
182
-		}
183
-
184
-		// user-defined primary color
185
-		if (!empty($user)) {
186
-			$userPrimaryColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'primary_color', '');
187
-			if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $userPrimaryColor)) {
188
-				return $userPrimaryColor;
189
-			}
190
-		}
191
-
192
-		// Finally, return the system global primary color
193
-		return $defaultColor;
194
-	}
195
-
196
-	/**
197
-	 * Color that is used for the page background (e.g. the header)
198
-	 * If user theming is enabled then the user defined value is returned
199
-	 */
200
-	public function getColorBackground(): string {
201
-		$user = $this->userSession->getUser();
202
-
203
-		// admin-defined background color
204
-		$defaultColor = $this->getDefaultColorBackground();
205
-
206
-		if ($this->isUserThemingDisabled()) {
207
-			return $defaultColor;
208
-		}
209
-
210
-		// user-defined background color
211
-		if (!empty($user)) {
212
-			$userBackgroundColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_color', '');
213
-			if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $userBackgroundColor)) {
214
-				return $userBackgroundColor;
215
-			}
216
-		}
217
-
218
-		// Finally, return the system global background color
219
-		return $defaultColor;
220
-	}
221
-
222
-	/**
223
-	 * Return the default primary color - only taking admin setting into account
224
-	 */
225
-	public function getDefaultColorPrimary(): string {
226
-		// try admin color
227
-		$defaultColor = $this->appConfig->getAppValueString('primary_color', '');
228
-		if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
229
-			return $defaultColor;
230
-		}
231
-
232
-		// fall back to default primary color
233
-		return $this->primaryColor;
234
-	}
235
-
236
-	/**
237
-	 * Default background color only taking admin setting into account
238
-	 */
239
-	public function getDefaultColorBackground(): string {
240
-		$defaultColor = $this->appConfig->getAppValueString('background_color');
241
-		if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
242
-			return $defaultColor;
243
-		}
244
-
245
-		return $this->backgroundColor;
246
-	}
247
-
248
-	/**
249
-	 * Themed logo url
250
-	 *
251
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
252
-	 * @return string
253
-	 */
254
-	public function getLogo($useSvg = true): string {
255
-		$logo = $this->appConfig->getAppValueString('logoMime', '');
256
-
257
-		// short cut to avoid setting up the filesystem just to check if the logo is there
258
-		//
259
-		// explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
260
-		// otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
261
-		// needs to be called then)
262
-		if ($useSvg === true && $logo !== '') {
263
-			$logoExists = true;
264
-		} else {
265
-			try {
266
-				$this->imageManager->getImage('logo', $useSvg);
267
-				$logoExists = true;
268
-			} catch (\Exception $e) {
269
-				$logoExists = false;
270
-			}
271
-		}
272
-
273
-		$cacheBusterCounter = (string)$this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
274
-		if (!$logo || !$logoExists) {
275
-			if ($useSvg) {
276
-				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
277
-			} else {
278
-				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
279
-			}
280
-			return $logo . '?v=' . $cacheBusterCounter;
281
-		}
282
-
283
-		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]);
284
-	}
285
-
286
-	/**
287
-	 * Themed background image url
288
-	 *
289
-	 * @param bool $darkVariant if the dark variant (if available) of the background should be used
290
-	 * @return string
291
-	 */
292
-	public function getBackground(bool $darkVariant = false): string {
293
-		return $this->imageManager->getImageUrl('background' . ($darkVariant ? 'Dark' : ''));
294
-	}
295
-
296
-	/**
297
-	 * @return string
298
-	 */
299
-	public function getiTunesAppId() {
300
-		return $this->appConfig->getAppValueString('iTunesAppId', $this->iTunesAppId);
301
-	}
302
-
303
-	/**
304
-	 * @return string
305
-	 */
306
-	public function getiOSClientUrl() {
307
-		return $this->appConfig->getAppValueString('iOSClientUrl', $this->iOSClientUrl);
308
-	}
309
-
310
-	/**
311
-	 * @return string
312
-	 */
313
-	public function getAndroidClientUrl() {
314
-		return $this->appConfig->getAppValueString('AndroidClientUrl', $this->AndroidClientUrl);
315
-	}
316
-
317
-	/**
318
-	 * @return string
319
-	 */
320
-	public function getFDroidClientUrl() {
321
-		return $this->appConfig->getAppValueString('FDroidClientUrl', $this->FDroidClientUrl);
322
-	}
323
-
324
-	/**
325
-	 * @return array scss variables to overwrite
326
-	 * @deprecated since Nextcloud 22 - https://github.com/nextcloud/server/issues/9940
327
-	 */
328
-	public function getScssVariables() {
329
-		$cacheBuster = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
330
-		$cache = $this->cacheFactory->createDistributed('theming-' . (string)$cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
331
-		if ($value = $cache->get('getScssVariables')) {
332
-			return $value;
333
-		}
334
-
335
-		$variables = [
336
-			'theming-cachebuster' => "'" . $cacheBuster . "'",
337
-			'theming-logo-mime' => "'" . $this->appConfig->getAppValueString('logoMime') . "'",
338
-			'theming-background-mime' => "'" . $this->appConfig->getAppValueString('backgroundMime') . "'",
339
-			'theming-logoheader-mime' => "'" . $this->appConfig->getAppValueString('logoheaderMime') . "'",
340
-			'theming-favicon-mime' => "'" . $this->appConfig->getAppValueString('faviconMime') . "'"
341
-		];
342
-
343
-		$variables['image-logo'] = "url('" . $this->imageManager->getImageUrl('logo') . "')";
344
-		$variables['image-logoheader'] = "url('" . $this->imageManager->getImageUrl('logoheader') . "')";
345
-		$variables['image-favicon'] = "url('" . $this->imageManager->getImageUrl('favicon') . "')";
346
-		$variables['image-login-background'] = "url('" . $this->imageManager->getImageUrl('background') . "')";
347
-		$variables['image-login-plain'] = 'false';
348
-
349
-		if ($this->appConfig->getAppValueString('primary_color', '') !== '') {
350
-			$variables['color-primary'] = $this->getColorPrimary();
351
-			$variables['color-primary-text'] = $this->getTextColorPrimary();
352
-			$variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
353
-		}
354
-
355
-		if ($this->appConfig->getAppValueString('backgroundMime', '') === 'backgroundColor') {
356
-			$variables['image-login-plain'] = 'true';
357
-		}
358
-
359
-		$variables['has-legal-links'] = 'false';
360
-		if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
361
-			$variables['has-legal-links'] = 'true';
362
-		}
363
-
364
-		$cache->set('getScssVariables', $variables);
365
-		return $variables;
366
-	}
367
-
368
-	/**
369
-	 * Check if the image should be replaced by the theming app
370
-	 * and return the new image location then
371
-	 *
372
-	 * @param string $app name of the app
373
-	 * @param string $image filename of the image
374
-	 * @return bool|string false if image should not replaced, otherwise the location of the image
375
-	 */
376
-	public function replaceImagePath($app, $image) {
377
-		if ($app === '' || $app === 'files_sharing') {
378
-			$app = 'core';
379
-		}
380
-
381
-		$route = false;
382
-		if ($image === 'favicon.ico' && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) {
383
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]);
384
-		}
385
-		if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) {
386
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]);
387
-		}
388
-		if ($image === 'manifest.json') {
389
-			try {
390
-				$appPath = $this->appManager->getAppPath($app);
391
-				if (file_exists($appPath . '/img/manifest.json')) {
392
-					return false;
393
-				}
394
-			} catch (AppPathNotFoundException $e) {
395
-			}
396
-			$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app ]);
397
-		}
398
-		if (str_starts_with($image, 'filetypes/') && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
399
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);
400
-		}
401
-
402
-		if ($route) {
403
-			return $route . '?v=' . $this->util->getCacheBuster();
404
-		}
405
-
406
-		return false;
407
-	}
408
-
409
-	protected function getCustomFavicon(): ?ISimpleFile {
410
-		try {
411
-			return $this->imageManager->getImage('favicon');
412
-		} catch (NotFoundException $e) {
413
-			return null;
414
-		}
415
-	}
416
-
417
-	/**
418
-	 * Increases the cache buster key
419
-	 */
420
-	public function increaseCacheBuster(): void {
421
-		$cacheBusterKey = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
422
-		$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, $cacheBusterKey + 1);
423
-		$this->cacheFactory->createDistributed('theming-')->clear();
424
-		$this->cacheFactory->createDistributed('imagePath')->clear();
425
-	}
426
-
427
-	/**
428
-	 * Update setting in the database
429
-	 *
430
-	 * @param string $setting
431
-	 * @param string $value
432
-	 */
433
-	public function set($setting, $value): void {
434
-		switch ($value) {
435
-			case ConfigLexicon::CACHE_BUSTER:
436
-				$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int)$value);
437
-				break;
438
-			case ConfigLexicon::USER_THEMING_DISABLED:
439
-				$value = $value === 'true' || $value === 'yes' || $value === '1';
440
-				$this->appConfig->setAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, $value);
441
-				break;
442
-			default:
443
-				$this->appConfig->setAppValueString($setting, $value);
444
-				break;
445
-		}
446
-		$this->increaseCacheBuster();
447
-	}
448
-
449
-	/**
450
-	 * Revert all settings to the default value
451
-	 */
452
-	public function undoAll(): void {
453
-		// Remember the current cachebuster value, as we do not want to reset this value
454
-		// Otherwise this can lead to caching issues as the value might be known to a browser already
455
-		$cacheBusterKey = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
456
-		$this->appConfig->deleteAppValues();
457
-		$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, $cacheBusterKey);
458
-		$this->increaseCacheBuster();
459
-	}
460
-
461
-	/**
462
-	 * Revert admin settings to the default value
463
-	 *
464
-	 * @param string $setting setting which should be reverted
465
-	 * @return string default value
466
-	 */
467
-	public function undo($setting): string {
468
-		$this->appConfig->deleteAppValue($setting);
469
-		$this->increaseCacheBuster();
470
-
471
-		$returnValue = '';
472
-		switch ($setting) {
473
-			case 'name':
474
-				$returnValue = $this->getEntity();
475
-				break;
476
-			case 'url':
477
-				$returnValue = $this->getBaseUrl();
478
-				break;
479
-			case 'slogan':
480
-				$returnValue = $this->getSlogan();
481
-				break;
482
-			case 'primary_color':
483
-				$returnValue = BackgroundService::DEFAULT_COLOR;
484
-				break;
485
-			case 'background_color':
486
-				// If a background image is set we revert to the mean image color
487
-				if ($this->imageManager->hasImage('background')) {
488
-					$file = $this->imageManager->getImage('background');
489
-					$returnValue = $this->backgroundService->setGlobalBackground($file->read()) ?? '';
490
-				}
491
-				break;
492
-			case 'logo':
493
-			case 'logoheader':
494
-			case 'background':
495
-			case 'favicon':
496
-				$this->imageManager->delete($setting);
497
-				$this->appConfig->deleteAppValue($setting . 'Mime');
498
-				break;
499
-		}
500
-
501
-		return $returnValue;
502
-	}
503
-
504
-	/**
505
-	 * Color of text in the header menu
506
-	 *
507
-	 * @return string
508
-	 */
509
-	public function getTextColorBackground() {
510
-		return $this->util->invertTextColor($this->getColorBackground()) ? '#000000' : '#ffffff';
511
-	}
512
-
513
-	/**
514
-	 * Color of text on primary buttons and other elements
515
-	 *
516
-	 * @return string
517
-	 */
518
-	public function getTextColorPrimary() {
519
-		return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
520
-	}
521
-
522
-	/**
523
-	 * Color of text in the header and primary buttons
524
-	 *
525
-	 * @return string
526
-	 */
527
-	public function getDefaultTextColorPrimary() {
528
-		return $this->util->invertTextColor($this->getDefaultColorPrimary()) ? '#000000' : '#ffffff';
529
-	}
530
-
531
-	/**
532
-	 * Has the admin disabled user customization
533
-	 */
534
-	public function isUserThemingDisabled(): bool {
535
-		return $this->appConfig->getAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, false);
536
-	}
25
+    private string $name;
26
+    private string $title;
27
+    private string $entity;
28
+    private string $productName;
29
+    private string $url;
30
+    private string $backgroundColor;
31
+    private string $primaryColor;
32
+    private string $docBaseUrl;
33
+
34
+    private string $iTunesAppId;
35
+    private string $iOSClientUrl;
36
+    private string $AndroidClientUrl;
37
+    private string $FDroidClientUrl;
38
+
39
+    /**
40
+     * ThemingDefaults constructor.
41
+     */
42
+    public function __construct(
43
+        private IConfig $config,
44
+        private IAppConfig $appConfig,
45
+        private IL10N $l,
46
+        private IUserSession $userSession,
47
+        private IURLGenerator $urlGenerator,
48
+        private ICacheFactory $cacheFactory,
49
+        private Util $util,
50
+        private ImageManager $imageManager,
51
+        private IAppManager $appManager,
52
+        private INavigationManager $navigationManager,
53
+        private BackgroundService $backgroundService,
54
+    ) {
55
+        parent::__construct();
56
+
57
+        $this->name = parent::getName();
58
+        $this->title = parent::getTitle();
59
+        $this->entity = parent::getEntity();
60
+        $this->productName = parent::getProductName();
61
+        $this->url = parent::getBaseUrl();
62
+        $this->primaryColor = parent::getColorPrimary();
63
+        $this->backgroundColor = parent::getColorBackground();
64
+        $this->iTunesAppId = parent::getiTunesAppId();
65
+        $this->iOSClientUrl = parent::getiOSClientUrl();
66
+        $this->AndroidClientUrl = parent::getAndroidClientUrl();
67
+        $this->FDroidClientUrl = parent::getFDroidClientUrl();
68
+        $this->docBaseUrl = parent::getDocBaseUrl();
69
+    }
70
+
71
+    public function getName() {
72
+        return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->name));
73
+    }
74
+
75
+    public function getHTMLName() {
76
+        return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->name);
77
+    }
78
+
79
+    public function getTitle() {
80
+        return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->title));
81
+    }
82
+
83
+    public function getEntity() {
84
+        return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_NAME, $this->entity));
85
+    }
86
+
87
+    public function getProductName() {
88
+        return strip_tags($this->appConfig->getAppValueString(ConfigLexicon::PRODUCT_NAME, $this->productName));
89
+    }
90
+
91
+    public function getBaseUrl() {
92
+        return $this->appConfig->getAppValueString(ConfigLexicon::BASE_URL, $this->url);
93
+    }
94
+
95
+    /**
96
+     * We pass a string and sanitizeHTML will return a string too in that case
97
+     * @psalm-suppress InvalidReturnStatement
98
+     * @psalm-suppress InvalidReturnType
99
+     */
100
+    public function getSlogan(?string $lang = null): string {
101
+        return \OCP\Util::sanitizeHTML($this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_SLOGAN, parent::getSlogan($lang)));
102
+    }
103
+
104
+    public function getImprintUrl(): string {
105
+        return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_IMPRINT_URL, '');
106
+    }
107
+
108
+    public function getPrivacyUrl(): string {
109
+        return $this->appConfig->getAppValueString(ConfigLexicon::INSTANCE_PRIVACY_URL, '');
110
+    }
111
+
112
+    public function getDocBaseUrl(): string {
113
+        return $this->appConfig->getAppValueString(ConfigLexicon::DOC_BASE_URL, $this->docBaseUrl);
114
+    }
115
+
116
+    public function getShortFooter() {
117
+        $slogan = $this->getSlogan();
118
+        $baseUrl = $this->getBaseUrl();
119
+        $entity = $this->getEntity();
120
+        $footer = '';
121
+
122
+        if ($entity !== '') {
123
+            if ($baseUrl !== '') {
124
+                $footer = '<a href="' . $baseUrl . '" target="_blank"'
125
+                    . ' rel="noreferrer noopener" class="entity-name">' . $entity . '</a>';
126
+            } else {
127
+                $footer = '<span class="entity-name">' . $entity . '</span>';
128
+            }
129
+        }
130
+        $footer .= ($slogan !== '' ? ' – ' . $slogan : '');
131
+
132
+        $links = [
133
+            [
134
+                'text' => $this->l->t('Legal notice'),
135
+                'url' => $this->getImprintUrl()
136
+            ],
137
+            [
138
+                'text' => $this->l->t('Privacy policy'),
139
+                'url' => $this->getPrivacyUrl()
140
+            ],
141
+        ];
142
+
143
+        $navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
144
+        $guestNavigation = array_map(function ($nav) {
145
+            return [
146
+                'text' => $nav['name'],
147
+                'url' => $nav['href']
148
+            ];
149
+        }, $navigation);
150
+        $links = array_merge($links, $guestNavigation);
151
+
152
+        $legalLinks = '';
153
+        $divider = '';
154
+        foreach ($links as $link) {
155
+            if ($link['url'] !== ''
156
+                && filter_var($link['url'], FILTER_VALIDATE_URL)
157
+            ) {
158
+                $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"'
159
+                    . ' rel="noreferrer noopener">' . $link['text'] . '</a>';
160
+                $divider = ' · ';
161
+            }
162
+        }
163
+        if ($legalLinks !== '') {
164
+            $footer .= '<br/><span class="footer__legal-links">' . $legalLinks . '</span>';
165
+        }
166
+
167
+        return $footer;
168
+    }
169
+
170
+    /**
171
+     * Color that is used for highlighting elements like important buttons
172
+     * If user theming is enabled then the user defined value is returned
173
+     */
174
+    public function getColorPrimary(): string {
175
+        $user = $this->userSession->getUser();
176
+
177
+        // admin-defined primary color
178
+        $defaultColor = $this->getDefaultColorPrimary();
179
+
180
+        if ($this->isUserThemingDisabled()) {
181
+            return $defaultColor;
182
+        }
183
+
184
+        // user-defined primary color
185
+        if (!empty($user)) {
186
+            $userPrimaryColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'primary_color', '');
187
+            if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $userPrimaryColor)) {
188
+                return $userPrimaryColor;
189
+            }
190
+        }
191
+
192
+        // Finally, return the system global primary color
193
+        return $defaultColor;
194
+    }
195
+
196
+    /**
197
+     * Color that is used for the page background (e.g. the header)
198
+     * If user theming is enabled then the user defined value is returned
199
+     */
200
+    public function getColorBackground(): string {
201
+        $user = $this->userSession->getUser();
202
+
203
+        // admin-defined background color
204
+        $defaultColor = $this->getDefaultColorBackground();
205
+
206
+        if ($this->isUserThemingDisabled()) {
207
+            return $defaultColor;
208
+        }
209
+
210
+        // user-defined background color
211
+        if (!empty($user)) {
212
+            $userBackgroundColor = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_color', '');
213
+            if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $userBackgroundColor)) {
214
+                return $userBackgroundColor;
215
+            }
216
+        }
217
+
218
+        // Finally, return the system global background color
219
+        return $defaultColor;
220
+    }
221
+
222
+    /**
223
+     * Return the default primary color - only taking admin setting into account
224
+     */
225
+    public function getDefaultColorPrimary(): string {
226
+        // try admin color
227
+        $defaultColor = $this->appConfig->getAppValueString('primary_color', '');
228
+        if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
229
+            return $defaultColor;
230
+        }
231
+
232
+        // fall back to default primary color
233
+        return $this->primaryColor;
234
+    }
235
+
236
+    /**
237
+     * Default background color only taking admin setting into account
238
+     */
239
+    public function getDefaultColorBackground(): string {
240
+        $defaultColor = $this->appConfig->getAppValueString('background_color');
241
+        if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
242
+            return $defaultColor;
243
+        }
244
+
245
+        return $this->backgroundColor;
246
+    }
247
+
248
+    /**
249
+     * Themed logo url
250
+     *
251
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
252
+     * @return string
253
+     */
254
+    public function getLogo($useSvg = true): string {
255
+        $logo = $this->appConfig->getAppValueString('logoMime', '');
256
+
257
+        // short cut to avoid setting up the filesystem just to check if the logo is there
258
+        //
259
+        // explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
260
+        // otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
261
+        // needs to be called then)
262
+        if ($useSvg === true && $logo !== '') {
263
+            $logoExists = true;
264
+        } else {
265
+            try {
266
+                $this->imageManager->getImage('logo', $useSvg);
267
+                $logoExists = true;
268
+            } catch (\Exception $e) {
269
+                $logoExists = false;
270
+            }
271
+        }
272
+
273
+        $cacheBusterCounter = (string)$this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
274
+        if (!$logo || !$logoExists) {
275
+            if ($useSvg) {
276
+                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
277
+            } else {
278
+                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
279
+            }
280
+            return $logo . '?v=' . $cacheBusterCounter;
281
+        }
282
+
283
+        return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]);
284
+    }
285
+
286
+    /**
287
+     * Themed background image url
288
+     *
289
+     * @param bool $darkVariant if the dark variant (if available) of the background should be used
290
+     * @return string
291
+     */
292
+    public function getBackground(bool $darkVariant = false): string {
293
+        return $this->imageManager->getImageUrl('background' . ($darkVariant ? 'Dark' : ''));
294
+    }
295
+
296
+    /**
297
+     * @return string
298
+     */
299
+    public function getiTunesAppId() {
300
+        return $this->appConfig->getAppValueString('iTunesAppId', $this->iTunesAppId);
301
+    }
302
+
303
+    /**
304
+     * @return string
305
+     */
306
+    public function getiOSClientUrl() {
307
+        return $this->appConfig->getAppValueString('iOSClientUrl', $this->iOSClientUrl);
308
+    }
309
+
310
+    /**
311
+     * @return string
312
+     */
313
+    public function getAndroidClientUrl() {
314
+        return $this->appConfig->getAppValueString('AndroidClientUrl', $this->AndroidClientUrl);
315
+    }
316
+
317
+    /**
318
+     * @return string
319
+     */
320
+    public function getFDroidClientUrl() {
321
+        return $this->appConfig->getAppValueString('FDroidClientUrl', $this->FDroidClientUrl);
322
+    }
323
+
324
+    /**
325
+     * @return array scss variables to overwrite
326
+     * @deprecated since Nextcloud 22 - https://github.com/nextcloud/server/issues/9940
327
+     */
328
+    public function getScssVariables() {
329
+        $cacheBuster = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
330
+        $cache = $this->cacheFactory->createDistributed('theming-' . (string)$cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
331
+        if ($value = $cache->get('getScssVariables')) {
332
+            return $value;
333
+        }
334
+
335
+        $variables = [
336
+            'theming-cachebuster' => "'" . $cacheBuster . "'",
337
+            'theming-logo-mime' => "'" . $this->appConfig->getAppValueString('logoMime') . "'",
338
+            'theming-background-mime' => "'" . $this->appConfig->getAppValueString('backgroundMime') . "'",
339
+            'theming-logoheader-mime' => "'" . $this->appConfig->getAppValueString('logoheaderMime') . "'",
340
+            'theming-favicon-mime' => "'" . $this->appConfig->getAppValueString('faviconMime') . "'"
341
+        ];
342
+
343
+        $variables['image-logo'] = "url('" . $this->imageManager->getImageUrl('logo') . "')";
344
+        $variables['image-logoheader'] = "url('" . $this->imageManager->getImageUrl('logoheader') . "')";
345
+        $variables['image-favicon'] = "url('" . $this->imageManager->getImageUrl('favicon') . "')";
346
+        $variables['image-login-background'] = "url('" . $this->imageManager->getImageUrl('background') . "')";
347
+        $variables['image-login-plain'] = 'false';
348
+
349
+        if ($this->appConfig->getAppValueString('primary_color', '') !== '') {
350
+            $variables['color-primary'] = $this->getColorPrimary();
351
+            $variables['color-primary-text'] = $this->getTextColorPrimary();
352
+            $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
353
+        }
354
+
355
+        if ($this->appConfig->getAppValueString('backgroundMime', '') === 'backgroundColor') {
356
+            $variables['image-login-plain'] = 'true';
357
+        }
358
+
359
+        $variables['has-legal-links'] = 'false';
360
+        if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
361
+            $variables['has-legal-links'] = 'true';
362
+        }
363
+
364
+        $cache->set('getScssVariables', $variables);
365
+        return $variables;
366
+    }
367
+
368
+    /**
369
+     * Check if the image should be replaced by the theming app
370
+     * and return the new image location then
371
+     *
372
+     * @param string $app name of the app
373
+     * @param string $image filename of the image
374
+     * @return bool|string false if image should not replaced, otherwise the location of the image
375
+     */
376
+    public function replaceImagePath($app, $image) {
377
+        if ($app === '' || $app === 'files_sharing') {
378
+            $app = 'core';
379
+        }
380
+
381
+        $route = false;
382
+        if ($image === 'favicon.ico' && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) {
383
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]);
384
+        }
385
+        if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($this->imageManager->shouldReplaceIcons() || $this->getCustomFavicon() !== null)) {
386
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]);
387
+        }
388
+        if ($image === 'manifest.json') {
389
+            try {
390
+                $appPath = $this->appManager->getAppPath($app);
391
+                if (file_exists($appPath . '/img/manifest.json')) {
392
+                    return false;
393
+                }
394
+            } catch (AppPathNotFoundException $e) {
395
+            }
396
+            $route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app ]);
397
+        }
398
+        if (str_starts_with($image, 'filetypes/') && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
399
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);
400
+        }
401
+
402
+        if ($route) {
403
+            return $route . '?v=' . $this->util->getCacheBuster();
404
+        }
405
+
406
+        return false;
407
+    }
408
+
409
+    protected function getCustomFavicon(): ?ISimpleFile {
410
+        try {
411
+            return $this->imageManager->getImage('favicon');
412
+        } catch (NotFoundException $e) {
413
+            return null;
414
+        }
415
+    }
416
+
417
+    /**
418
+     * Increases the cache buster key
419
+     */
420
+    public function increaseCacheBuster(): void {
421
+        $cacheBusterKey = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
422
+        $this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, $cacheBusterKey + 1);
423
+        $this->cacheFactory->createDistributed('theming-')->clear();
424
+        $this->cacheFactory->createDistributed('imagePath')->clear();
425
+    }
426
+
427
+    /**
428
+     * Update setting in the database
429
+     *
430
+     * @param string $setting
431
+     * @param string $value
432
+     */
433
+    public function set($setting, $value): void {
434
+        switch ($value) {
435
+            case ConfigLexicon::CACHE_BUSTER:
436
+                $this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int)$value);
437
+                break;
438
+            case ConfigLexicon::USER_THEMING_DISABLED:
439
+                $value = $value === 'true' || $value === 'yes' || $value === '1';
440
+                $this->appConfig->setAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, $value);
441
+                break;
442
+            default:
443
+                $this->appConfig->setAppValueString($setting, $value);
444
+                break;
445
+        }
446
+        $this->increaseCacheBuster();
447
+    }
448
+
449
+    /**
450
+     * Revert all settings to the default value
451
+     */
452
+    public function undoAll(): void {
453
+        // Remember the current cachebuster value, as we do not want to reset this value
454
+        // Otherwise this can lead to caching issues as the value might be known to a browser already
455
+        $cacheBusterKey = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
456
+        $this->appConfig->deleteAppValues();
457
+        $this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, $cacheBusterKey);
458
+        $this->increaseCacheBuster();
459
+    }
460
+
461
+    /**
462
+     * Revert admin settings to the default value
463
+     *
464
+     * @param string $setting setting which should be reverted
465
+     * @return string default value
466
+     */
467
+    public function undo($setting): string {
468
+        $this->appConfig->deleteAppValue($setting);
469
+        $this->increaseCacheBuster();
470
+
471
+        $returnValue = '';
472
+        switch ($setting) {
473
+            case 'name':
474
+                $returnValue = $this->getEntity();
475
+                break;
476
+            case 'url':
477
+                $returnValue = $this->getBaseUrl();
478
+                break;
479
+            case 'slogan':
480
+                $returnValue = $this->getSlogan();
481
+                break;
482
+            case 'primary_color':
483
+                $returnValue = BackgroundService::DEFAULT_COLOR;
484
+                break;
485
+            case 'background_color':
486
+                // If a background image is set we revert to the mean image color
487
+                if ($this->imageManager->hasImage('background')) {
488
+                    $file = $this->imageManager->getImage('background');
489
+                    $returnValue = $this->backgroundService->setGlobalBackground($file->read()) ?? '';
490
+                }
491
+                break;
492
+            case 'logo':
493
+            case 'logoheader':
494
+            case 'background':
495
+            case 'favicon':
496
+                $this->imageManager->delete($setting);
497
+                $this->appConfig->deleteAppValue($setting . 'Mime');
498
+                break;
499
+        }
500
+
501
+        return $returnValue;
502
+    }
503
+
504
+    /**
505
+     * Color of text in the header menu
506
+     *
507
+     * @return string
508
+     */
509
+    public function getTextColorBackground() {
510
+        return $this->util->invertTextColor($this->getColorBackground()) ? '#000000' : '#ffffff';
511
+    }
512
+
513
+    /**
514
+     * Color of text on primary buttons and other elements
515
+     *
516
+     * @return string
517
+     */
518
+    public function getTextColorPrimary() {
519
+        return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
520
+    }
521
+
522
+    /**
523
+     * Color of text in the header and primary buttons
524
+     *
525
+     * @return string
526
+     */
527
+    public function getDefaultTextColorPrimary() {
528
+        return $this->util->invertTextColor($this->getDefaultColorPrimary()) ? '#000000' : '#ffffff';
529
+    }
530
+
531
+    /**
532
+     * Has the admin disabled user customization
533
+     */
534
+    public function isUserThemingDisabled(): bool {
535
+        return $this->appConfig->getAppValueBool(ConfigLexicon::USER_THEMING_DISABLED, false);
536
+    }
537 537
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
 
122 122
 		if ($entity !== '') {
123 123
 			if ($baseUrl !== '') {
124
-				$footer = '<a href="' . $baseUrl . '" target="_blank"'
125
-					. ' rel="noreferrer noopener" class="entity-name">' . $entity . '</a>';
124
+				$footer = '<a href="'.$baseUrl.'" target="_blank"'
125
+					. ' rel="noreferrer noopener" class="entity-name">'.$entity.'</a>';
126 126
 			} else {
127
-				$footer = '<span class="entity-name">' . $entity . '</span>';
127
+				$footer = '<span class="entity-name">'.$entity.'</span>';
128 128
 			}
129 129
 		}
130
-		$footer .= ($slogan !== '' ? ' – ' . $slogan : '');
130
+		$footer .= ($slogan !== '' ? ' – '.$slogan : '');
131 131
 
132 132
 		$links = [
133 133
 			[
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		];
142 142
 
143 143
 		$navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
144
-		$guestNavigation = array_map(function ($nav) {
144
+		$guestNavigation = array_map(function($nav) {
145 145
 			return [
146 146
 				'text' => $nav['name'],
147 147
 				'url' => $nav['href']
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 			if ($link['url'] !== ''
156 156
 				&& filter_var($link['url'], FILTER_VALIDATE_URL)
157 157
 			) {
158
-				$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"'
159
-					. ' rel="noreferrer noopener">' . $link['text'] . '</a>';
158
+				$legalLinks .= $divider.'<a href="'.$link['url'].'" class="legal" target="_blank"'
159
+					. ' rel="noreferrer noopener">'.$link['text'].'</a>';
160 160
 				$divider = ' · ';
161 161
 			}
162 162
 		}
163 163
 		if ($legalLinks !== '') {
164
-			$footer .= '<br/><span class="footer__legal-links">' . $legalLinks . '</span>';
164
+			$footer .= '<br/><span class="footer__legal-links">'.$legalLinks.'</span>';
165 165
 		}
166 166
 
167 167
 		return $footer;
@@ -270,17 +270,17 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 		}
272 272
 
273
-		$cacheBusterCounter = (string)$this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
273
+		$cacheBusterCounter = (string) $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
274 274
 		if (!$logo || !$logoExists) {
275 275
 			if ($useSvg) {
276 276
 				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
277 277
 			} else {
278 278
 				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
279 279
 			}
280
-			return $logo . '?v=' . $cacheBusterCounter;
280
+			return $logo.'?v='.$cacheBusterCounter;
281 281
 		}
282 282
 
283
-		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]);
283
+		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter]);
284 284
 	}
285 285
 
286 286
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return string
291 291
 	 */
292 292
 	public function getBackground(bool $darkVariant = false): string {
293
-		return $this->imageManager->getImageUrl('background' . ($darkVariant ? 'Dark' : ''));
293
+		return $this->imageManager->getImageUrl('background'.($darkVariant ? 'Dark' : ''));
294 294
 	}
295 295
 
296 296
 	/**
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	public function getScssVariables() {
329 329
 		$cacheBuster = $this->appConfig->getAppValueInt(ConfigLexicon::CACHE_BUSTER);
330
-		$cache = $this->cacheFactory->createDistributed('theming-' . (string)$cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
330
+		$cache = $this->cacheFactory->createDistributed('theming-'.(string) $cacheBuster.'-'.$this->urlGenerator->getBaseUrl());
331 331
 		if ($value = $cache->get('getScssVariables')) {
332 332
 			return $value;
333 333
 		}
334 334
 
335 335
 		$variables = [
336
-			'theming-cachebuster' => "'" . $cacheBuster . "'",
337
-			'theming-logo-mime' => "'" . $this->appConfig->getAppValueString('logoMime') . "'",
338
-			'theming-background-mime' => "'" . $this->appConfig->getAppValueString('backgroundMime') . "'",
339
-			'theming-logoheader-mime' => "'" . $this->appConfig->getAppValueString('logoheaderMime') . "'",
340
-			'theming-favicon-mime' => "'" . $this->appConfig->getAppValueString('faviconMime') . "'"
336
+			'theming-cachebuster' => "'".$cacheBuster."'",
337
+			'theming-logo-mime' => "'".$this->appConfig->getAppValueString('logoMime')."'",
338
+			'theming-background-mime' => "'".$this->appConfig->getAppValueString('backgroundMime')."'",
339
+			'theming-logoheader-mime' => "'".$this->appConfig->getAppValueString('logoheaderMime')."'",
340
+			'theming-favicon-mime' => "'".$this->appConfig->getAppValueString('faviconMime')."'"
341 341
 		];
342 342
 
343
-		$variables['image-logo'] = "url('" . $this->imageManager->getImageUrl('logo') . "')";
344
-		$variables['image-logoheader'] = "url('" . $this->imageManager->getImageUrl('logoheader') . "')";
345
-		$variables['image-favicon'] = "url('" . $this->imageManager->getImageUrl('favicon') . "')";
346
-		$variables['image-login-background'] = "url('" . $this->imageManager->getImageUrl('background') . "')";
343
+		$variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')";
344
+		$variables['image-logoheader'] = "url('".$this->imageManager->getImageUrl('logoheader')."')";
345
+		$variables['image-favicon'] = "url('".$this->imageManager->getImageUrl('favicon')."')";
346
+		$variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')";
347 347
 		$variables['image-login-plain'] = 'false';
348 348
 
349 349
 		if ($this->appConfig->getAppValueString('primary_color', '') !== '') {
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 		if ($image === 'manifest.json') {
389 389
 			try {
390 390
 				$appPath = $this->appManager->getAppPath($app);
391
-				if (file_exists($appPath . '/img/manifest.json')) {
391
+				if (file_exists($appPath.'/img/manifest.json')) {
392 392
 					return false;
393 393
 				}
394 394
 			} catch (AppPathNotFoundException $e) {
395 395
 			}
396
-			$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app ]);
396
+			$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest', ['app' => $app]);
397 397
 		}
398
-		if (str_starts_with($image, 'filetypes/') && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
398
+		if (str_starts_with($image, 'filetypes/') && file_exists(\OC::$SERVERROOT.'/core/img/'.$image)) {
399 399
 			$route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);
400 400
 		}
401 401
 
402 402
 		if ($route) {
403
-			return $route . '?v=' . $this->util->getCacheBuster();
403
+			return $route.'?v='.$this->util->getCacheBuster();
404 404
 		}
405 405
 
406 406
 		return false;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	public function set($setting, $value): void {
434 434
 		switch ($value) {
435 435
 			case ConfigLexicon::CACHE_BUSTER:
436
-				$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int)$value);
436
+				$this->appConfig->setAppValueInt(ConfigLexicon::CACHE_BUSTER, (int) $value);
437 437
 				break;
438 438
 			case ConfigLexicon::USER_THEMING_DISABLED:
439 439
 				$value = $value === 'true' || $value === 'yes' || $value === '1';
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 			case 'background':
495 495
 			case 'favicon':
496 496
 				$this->imageManager->delete($setting);
497
-				$this->appConfig->deleteAppValue($setting . 'Mime');
497
+				$this->appConfig->deleteAppValue($setting.'Mime');
498 498
 				break;
499 499
 		}
500 500
 
Please login to merge, or discard this patch.
apps/theming/lib/ConfigLexicon.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -21,96 +21,96 @@
 block discarded – undo
21 21
  * {@see ILexicon}
22 22
  */
23 23
 class ConfigLexicon implements ILexicon {
24
-	/** The cache buster index */
25
-	public const CACHE_BUSTER = 'cachebuster';
26
-	public const USER_THEMING_DISABLED = 'disable-user-theming';
24
+    /** The cache buster index */
25
+    public const CACHE_BUSTER = 'cachebuster';
26
+    public const USER_THEMING_DISABLED = 'disable-user-theming';
27 27
 
28
-	/** Name of the software running on this instance (usually "Nextcloud") */
29
-	public const PRODUCT_NAME = 'productName';
30
-	/** Short name of this instance */
31
-	public const INSTANCE_NAME = 'name';
32
-	/** Slogan of this instance */
33
-	public const INSTANCE_SLOGAN = 'slogan';
34
-	/** Imprint URL of this instance */
35
-	public const INSTANCE_IMPRINT_URL = 'imprintUrl';
36
-	/** Privacy URL of this instance */
37
-	public const INSTANCE_PRIVACY_URL = 'privacyUrl';
28
+    /** Name of the software running on this instance (usually "Nextcloud") */
29
+    public const PRODUCT_NAME = 'productName';
30
+    /** Short name of this instance */
31
+    public const INSTANCE_NAME = 'name';
32
+    /** Slogan of this instance */
33
+    public const INSTANCE_SLOGAN = 'slogan';
34
+    /** Imprint URL of this instance */
35
+    public const INSTANCE_IMPRINT_URL = 'imprintUrl';
36
+    /** Privacy URL of this instance */
37
+    public const INSTANCE_PRIVACY_URL = 'privacyUrl';
38 38
 
39
-	// legacy theming
40
-	/** Base URL of this instance */
41
-	public const BASE_URL = 'url';
42
-	/** Base URL for documentation */
43
-	public const DOC_BASE_URL = 'docBaseUrl';
39
+    // legacy theming
40
+    /** Base URL of this instance */
41
+    public const BASE_URL = 'url';
42
+    /** Base URL for documentation */
43
+    public const DOC_BASE_URL = 'docBaseUrl';
44 44
 
45
-	public function getStrictness(): Strictness {
46
-		return Strictness::NOTICE;
47
-	}
45
+    public function getStrictness(): Strictness {
46
+        return Strictness::NOTICE;
47
+    }
48 48
 
49
-	public function getAppConfigs(): array {
50
-		return [
51
-			// internals
52
-			new Entry(
53
-				self::CACHE_BUSTER,
54
-				ValueType::INT,
55
-				defaultRaw: 0,
56
-				definition: 'The current cache buster key for theming assets.',
57
-			),
58
-			new Entry(
59
-				self::USER_THEMING_DISABLED,
60
-				ValueType::BOOL,
61
-				defaultRaw: false,
62
-				definition: 'Whether user theming is disabled.',
63
-			),
49
+    public function getAppConfigs(): array {
50
+        return [
51
+            // internals
52
+            new Entry(
53
+                self::CACHE_BUSTER,
54
+                ValueType::INT,
55
+                defaultRaw: 0,
56
+                definition: 'The current cache buster key for theming assets.',
57
+            ),
58
+            new Entry(
59
+                self::USER_THEMING_DISABLED,
60
+                ValueType::BOOL,
61
+                defaultRaw: false,
62
+                definition: 'Whether user theming is disabled.',
63
+            ),
64 64
 
65
-			// instance theming
66
-			new Entry(
67
-				self::PRODUCT_NAME,
68
-				ValueType::STRING,
69
-				defaultRaw: 'Nextcloud',
70
-				definition: 'The name of the software running on this instance (usually "Nextcloud").',
71
-			),
72
-			new Entry(
73
-				self::INSTANCE_NAME,
74
-				ValueType::STRING,
75
-				defaultRaw: '',
76
-				definition: 'Short name of this instance.',
77
-			),
78
-			new Entry(
79
-				self::INSTANCE_SLOGAN,
80
-				ValueType::STRING,
81
-				defaultRaw: '',
82
-				definition: 'Slogan of this instance.',
83
-			),
84
-			new Entry(
85
-				self::INSTANCE_IMPRINT_URL,
86
-				ValueType::STRING,
87
-				defaultRaw: '',
88
-				definition: 'Imprint URL of this instance.',
89
-			),
90
-			new Entry(
91
-				self::INSTANCE_PRIVACY_URL,
92
-				ValueType::STRING,
93
-				defaultRaw: '',
94
-				definition: 'Privacy URL of this instance.',
95
-			),
65
+            // instance theming
66
+            new Entry(
67
+                self::PRODUCT_NAME,
68
+                ValueType::STRING,
69
+                defaultRaw: 'Nextcloud',
70
+                definition: 'The name of the software running on this instance (usually "Nextcloud").',
71
+            ),
72
+            new Entry(
73
+                self::INSTANCE_NAME,
74
+                ValueType::STRING,
75
+                defaultRaw: '',
76
+                definition: 'Short name of this instance.',
77
+            ),
78
+            new Entry(
79
+                self::INSTANCE_SLOGAN,
80
+                ValueType::STRING,
81
+                defaultRaw: '',
82
+                definition: 'Slogan of this instance.',
83
+            ),
84
+            new Entry(
85
+                self::INSTANCE_IMPRINT_URL,
86
+                ValueType::STRING,
87
+                defaultRaw: '',
88
+                definition: 'Imprint URL of this instance.',
89
+            ),
90
+            new Entry(
91
+                self::INSTANCE_PRIVACY_URL,
92
+                ValueType::STRING,
93
+                defaultRaw: '',
94
+                definition: 'Privacy URL of this instance.',
95
+            ),
96 96
 
97
-			// legacy theming
98
-			new Entry(
99
-				self::BASE_URL,
100
-				ValueType::STRING,
101
-				defaultRaw: '',
102
-				definition: 'Base URL of this instance.',
103
-			),
104
-			new Entry(
105
-				self::DOC_BASE_URL,
106
-				ValueType::STRING,
107
-				defaultRaw: '',
108
-				definition: 'Base URL for documentation.',
109
-			),
110
-		];
111
-	}
97
+            // legacy theming
98
+            new Entry(
99
+                self::BASE_URL,
100
+                ValueType::STRING,
101
+                defaultRaw: '',
102
+                definition: 'Base URL of this instance.',
103
+            ),
104
+            new Entry(
105
+                self::DOC_BASE_URL,
106
+                ValueType::STRING,
107
+                defaultRaw: '',
108
+                definition: 'Base URL for documentation.',
109
+            ),
110
+        ];
111
+    }
112 112
 
113
-	public function getUserConfigs(): array {
114
-		return [];
115
-	}
113
+    public function getUserConfigs(): array {
114
+        return [];
115
+    }
116 116
 }
Please login to merge, or discard this patch.
apps/theming/composer/composer/autoload_static.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,62 +6,62 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitTheming
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Theming\\' => 12,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Theming\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25
-        'OCA\\Theming\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
26
-        'OCA\\Theming\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
27
-        'OCA\\Theming\\Command\\UpdateConfig' => __DIR__ . '/..' . '/../lib/Command/UpdateConfig.php',
28
-        'OCA\\Theming\\ConfigLexicon' => __DIR__ . '/..' . '/../lib/ConfigLexicon.php',
29
-        'OCA\\Theming\\Controller\\IconController' => __DIR__ . '/..' . '/../lib/Controller/IconController.php',
30
-        'OCA\\Theming\\Controller\\ThemingController' => __DIR__ . '/..' . '/../lib/Controller/ThemingController.php',
31
-        'OCA\\Theming\\Controller\\UserThemeController' => __DIR__ . '/..' . '/../lib/Controller/UserThemeController.php',
32
-        'OCA\\Theming\\ITheme' => __DIR__ . '/..' . '/../lib/ITheme.php',
33
-        'OCA\\Theming\\IconBuilder' => __DIR__ . '/..' . '/../lib/IconBuilder.php',
34
-        'OCA\\Theming\\ImageManager' => __DIR__ . '/..' . '/../lib/ImageManager.php',
35
-        'OCA\\Theming\\Jobs\\MigrateBackgroundImages' => __DIR__ . '/..' . '/../lib/Jobs/MigrateBackgroundImages.php',
36
-        'OCA\\Theming\\Jobs\\RestoreBackgroundImageColor' => __DIR__ . '/..' . '/../lib/Jobs/RestoreBackgroundImageColor.php',
37
-        'OCA\\Theming\\Listener\\BeforePreferenceListener' => __DIR__ . '/..' . '/../lib/Listener/BeforePreferenceListener.php',
38
-        'OCA\\Theming\\Listener\\BeforeTemplateRenderedListener' => __DIR__ . '/..' . '/../lib/Listener/BeforeTemplateRenderedListener.php',
39
-        'OCA\\Theming\\Migration\\InitBackgroundImagesMigration' => __DIR__ . '/..' . '/../lib/Migration/InitBackgroundImagesMigration.php',
40
-        'OCA\\Theming\\Migration\\Version2006Date20240905111627' => __DIR__ . '/..' . '/../lib/Migration/Version2006Date20240905111627.php',
41
-        'OCA\\Theming\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
42
-        'OCA\\Theming\\Service\\BackgroundService' => __DIR__ . '/..' . '/../lib/Service/BackgroundService.php',
43
-        'OCA\\Theming\\Service\\JSDataService' => __DIR__ . '/..' . '/../lib/Service/JSDataService.php',
44
-        'OCA\\Theming\\Service\\ThemeInjectionService' => __DIR__ . '/..' . '/../lib/Service/ThemeInjectionService.php',
45
-        'OCA\\Theming\\Service\\ThemesService' => __DIR__ . '/..' . '/../lib/Service/ThemesService.php',
46
-        'OCA\\Theming\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
47
-        'OCA\\Theming\\Settings\\AdminSection' => __DIR__ . '/..' . '/../lib/Settings/AdminSection.php',
48
-        'OCA\\Theming\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
49
-        'OCA\\Theming\\Settings\\PersonalSection' => __DIR__ . '/..' . '/../lib/Settings/PersonalSection.php',
50
-        'OCA\\Theming\\SetupChecks\\PhpImagickModule' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpImagickModule.php',
51
-        'OCA\\Theming\\Themes\\CommonThemeTrait' => __DIR__ . '/..' . '/../lib/Themes/CommonThemeTrait.php',
52
-        'OCA\\Theming\\Themes\\DarkHighContrastTheme' => __DIR__ . '/..' . '/../lib/Themes/DarkHighContrastTheme.php',
53
-        'OCA\\Theming\\Themes\\DarkTheme' => __DIR__ . '/..' . '/../lib/Themes/DarkTheme.php',
54
-        'OCA\\Theming\\Themes\\DefaultTheme' => __DIR__ . '/..' . '/../lib/Themes/DefaultTheme.php',
55
-        'OCA\\Theming\\Themes\\DyslexiaFont' => __DIR__ . '/..' . '/../lib/Themes/DyslexiaFont.php',
56
-        'OCA\\Theming\\Themes\\HighContrastTheme' => __DIR__ . '/..' . '/../lib/Themes/HighContrastTheme.php',
57
-        'OCA\\Theming\\Themes\\LightTheme' => __DIR__ . '/..' . '/../lib/Themes/LightTheme.php',
58
-        'OCA\\Theming\\ThemingDefaults' => __DIR__ . '/..' . '/../lib/ThemingDefaults.php',
59
-        'OCA\\Theming\\Util' => __DIR__ . '/..' . '/../lib/Util.php',
23
+    public static $classMap = array(
24
+        'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php',
25
+        'OCA\\Theming\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
26
+        'OCA\\Theming\\Capabilities' => __DIR__.'/..'.'/../lib/Capabilities.php',
27
+        'OCA\\Theming\\Command\\UpdateConfig' => __DIR__.'/..'.'/../lib/Command/UpdateConfig.php',
28
+        'OCA\\Theming\\ConfigLexicon' => __DIR__.'/..'.'/../lib/ConfigLexicon.php',
29
+        'OCA\\Theming\\Controller\\IconController' => __DIR__.'/..'.'/../lib/Controller/IconController.php',
30
+        'OCA\\Theming\\Controller\\ThemingController' => __DIR__.'/..'.'/../lib/Controller/ThemingController.php',
31
+        'OCA\\Theming\\Controller\\UserThemeController' => __DIR__.'/..'.'/../lib/Controller/UserThemeController.php',
32
+        'OCA\\Theming\\ITheme' => __DIR__.'/..'.'/../lib/ITheme.php',
33
+        'OCA\\Theming\\IconBuilder' => __DIR__.'/..'.'/../lib/IconBuilder.php',
34
+        'OCA\\Theming\\ImageManager' => __DIR__.'/..'.'/../lib/ImageManager.php',
35
+        'OCA\\Theming\\Jobs\\MigrateBackgroundImages' => __DIR__.'/..'.'/../lib/Jobs/MigrateBackgroundImages.php',
36
+        'OCA\\Theming\\Jobs\\RestoreBackgroundImageColor' => __DIR__.'/..'.'/../lib/Jobs/RestoreBackgroundImageColor.php',
37
+        'OCA\\Theming\\Listener\\BeforePreferenceListener' => __DIR__.'/..'.'/../lib/Listener/BeforePreferenceListener.php',
38
+        'OCA\\Theming\\Listener\\BeforeTemplateRenderedListener' => __DIR__.'/..'.'/../lib/Listener/BeforeTemplateRenderedListener.php',
39
+        'OCA\\Theming\\Migration\\InitBackgroundImagesMigration' => __DIR__.'/..'.'/../lib/Migration/InitBackgroundImagesMigration.php',
40
+        'OCA\\Theming\\Migration\\Version2006Date20240905111627' => __DIR__.'/..'.'/../lib/Migration/Version2006Date20240905111627.php',
41
+        'OCA\\Theming\\ResponseDefinitions' => __DIR__.'/..'.'/../lib/ResponseDefinitions.php',
42
+        'OCA\\Theming\\Service\\BackgroundService' => __DIR__.'/..'.'/../lib/Service/BackgroundService.php',
43
+        'OCA\\Theming\\Service\\JSDataService' => __DIR__.'/..'.'/../lib/Service/JSDataService.php',
44
+        'OCA\\Theming\\Service\\ThemeInjectionService' => __DIR__.'/..'.'/../lib/Service/ThemeInjectionService.php',
45
+        'OCA\\Theming\\Service\\ThemesService' => __DIR__.'/..'.'/../lib/Service/ThemesService.php',
46
+        'OCA\\Theming\\Settings\\Admin' => __DIR__.'/..'.'/../lib/Settings/Admin.php',
47
+        'OCA\\Theming\\Settings\\AdminSection' => __DIR__.'/..'.'/../lib/Settings/AdminSection.php',
48
+        'OCA\\Theming\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php',
49
+        'OCA\\Theming\\Settings\\PersonalSection' => __DIR__.'/..'.'/../lib/Settings/PersonalSection.php',
50
+        'OCA\\Theming\\SetupChecks\\PhpImagickModule' => __DIR__.'/..'.'/../lib/SetupChecks/PhpImagickModule.php',
51
+        'OCA\\Theming\\Themes\\CommonThemeTrait' => __DIR__.'/..'.'/../lib/Themes/CommonThemeTrait.php',
52
+        'OCA\\Theming\\Themes\\DarkHighContrastTheme' => __DIR__.'/..'.'/../lib/Themes/DarkHighContrastTheme.php',
53
+        'OCA\\Theming\\Themes\\DarkTheme' => __DIR__.'/..'.'/../lib/Themes/DarkTheme.php',
54
+        'OCA\\Theming\\Themes\\DefaultTheme' => __DIR__.'/..'.'/../lib/Themes/DefaultTheme.php',
55
+        'OCA\\Theming\\Themes\\DyslexiaFont' => __DIR__.'/..'.'/../lib/Themes/DyslexiaFont.php',
56
+        'OCA\\Theming\\Themes\\HighContrastTheme' => __DIR__.'/..'.'/../lib/Themes/HighContrastTheme.php',
57
+        'OCA\\Theming\\Themes\\LightTheme' => __DIR__.'/..'.'/../lib/Themes/LightTheme.php',
58
+        'OCA\\Theming\\ThemingDefaults' => __DIR__.'/..'.'/../lib/ThemingDefaults.php',
59
+        'OCA\\Theming\\Util' => __DIR__.'/..'.'/../lib/Util.php',
60 60
     );
61 61
 
62 62
     public static function getInitializer(ClassLoader $loader)
63 63
     {
64
-        return \Closure::bind(function () use ($loader) {
64
+        return \Closure::bind(function() use ($loader) {
65 65
             $loader->prefixLengthsPsr4 = ComposerStaticInitTheming::$prefixLengthsPsr4;
66 66
             $loader->prefixDirsPsr4 = ComposerStaticInitTheming::$prefixDirsPsr4;
67 67
             $loader->classMap = ComposerStaticInitTheming::$classMap;
Please login to merge, or discard this patch.
apps/theming/composer/composer/autoload_classmap.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,40 +6,40 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10
-    'OCA\\Theming\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
11
-    'OCA\\Theming\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
12
-    'OCA\\Theming\\Command\\UpdateConfig' => $baseDir . '/../lib/Command/UpdateConfig.php',
13
-    'OCA\\Theming\\ConfigLexicon' => $baseDir . '/../lib/ConfigLexicon.php',
14
-    'OCA\\Theming\\Controller\\IconController' => $baseDir . '/../lib/Controller/IconController.php',
15
-    'OCA\\Theming\\Controller\\ThemingController' => $baseDir . '/../lib/Controller/ThemingController.php',
16
-    'OCA\\Theming\\Controller\\UserThemeController' => $baseDir . '/../lib/Controller/UserThemeController.php',
17
-    'OCA\\Theming\\ITheme' => $baseDir . '/../lib/ITheme.php',
18
-    'OCA\\Theming\\IconBuilder' => $baseDir . '/../lib/IconBuilder.php',
19
-    'OCA\\Theming\\ImageManager' => $baseDir . '/../lib/ImageManager.php',
20
-    'OCA\\Theming\\Jobs\\MigrateBackgroundImages' => $baseDir . '/../lib/Jobs/MigrateBackgroundImages.php',
21
-    'OCA\\Theming\\Jobs\\RestoreBackgroundImageColor' => $baseDir . '/../lib/Jobs/RestoreBackgroundImageColor.php',
22
-    'OCA\\Theming\\Listener\\BeforePreferenceListener' => $baseDir . '/../lib/Listener/BeforePreferenceListener.php',
23
-    'OCA\\Theming\\Listener\\BeforeTemplateRenderedListener' => $baseDir . '/../lib/Listener/BeforeTemplateRenderedListener.php',
24
-    'OCA\\Theming\\Migration\\InitBackgroundImagesMigration' => $baseDir . '/../lib/Migration/InitBackgroundImagesMigration.php',
25
-    'OCA\\Theming\\Migration\\Version2006Date20240905111627' => $baseDir . '/../lib/Migration/Version2006Date20240905111627.php',
26
-    'OCA\\Theming\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
27
-    'OCA\\Theming\\Service\\BackgroundService' => $baseDir . '/../lib/Service/BackgroundService.php',
28
-    'OCA\\Theming\\Service\\JSDataService' => $baseDir . '/../lib/Service/JSDataService.php',
29
-    'OCA\\Theming\\Service\\ThemeInjectionService' => $baseDir . '/../lib/Service/ThemeInjectionService.php',
30
-    'OCA\\Theming\\Service\\ThemesService' => $baseDir . '/../lib/Service/ThemesService.php',
31
-    'OCA\\Theming\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
32
-    'OCA\\Theming\\Settings\\AdminSection' => $baseDir . '/../lib/Settings/AdminSection.php',
33
-    'OCA\\Theming\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
34
-    'OCA\\Theming\\Settings\\PersonalSection' => $baseDir . '/../lib/Settings/PersonalSection.php',
35
-    'OCA\\Theming\\SetupChecks\\PhpImagickModule' => $baseDir . '/../lib/SetupChecks/PhpImagickModule.php',
36
-    'OCA\\Theming\\Themes\\CommonThemeTrait' => $baseDir . '/../lib/Themes/CommonThemeTrait.php',
37
-    'OCA\\Theming\\Themes\\DarkHighContrastTheme' => $baseDir . '/../lib/Themes/DarkHighContrastTheme.php',
38
-    'OCA\\Theming\\Themes\\DarkTheme' => $baseDir . '/../lib/Themes/DarkTheme.php',
39
-    'OCA\\Theming\\Themes\\DefaultTheme' => $baseDir . '/../lib/Themes/DefaultTheme.php',
40
-    'OCA\\Theming\\Themes\\DyslexiaFont' => $baseDir . '/../lib/Themes/DyslexiaFont.php',
41
-    'OCA\\Theming\\Themes\\HighContrastTheme' => $baseDir . '/../lib/Themes/HighContrastTheme.php',
42
-    'OCA\\Theming\\Themes\\LightTheme' => $baseDir . '/../lib/Themes/LightTheme.php',
43
-    'OCA\\Theming\\ThemingDefaults' => $baseDir . '/../lib/ThemingDefaults.php',
44
-    'OCA\\Theming\\Util' => $baseDir . '/../lib/Util.php',
9
+    'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php',
10
+    'OCA\\Theming\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
11
+    'OCA\\Theming\\Capabilities' => $baseDir.'/../lib/Capabilities.php',
12
+    'OCA\\Theming\\Command\\UpdateConfig' => $baseDir.'/../lib/Command/UpdateConfig.php',
13
+    'OCA\\Theming\\ConfigLexicon' => $baseDir.'/../lib/ConfigLexicon.php',
14
+    'OCA\\Theming\\Controller\\IconController' => $baseDir.'/../lib/Controller/IconController.php',
15
+    'OCA\\Theming\\Controller\\ThemingController' => $baseDir.'/../lib/Controller/ThemingController.php',
16
+    'OCA\\Theming\\Controller\\UserThemeController' => $baseDir.'/../lib/Controller/UserThemeController.php',
17
+    'OCA\\Theming\\ITheme' => $baseDir.'/../lib/ITheme.php',
18
+    'OCA\\Theming\\IconBuilder' => $baseDir.'/../lib/IconBuilder.php',
19
+    'OCA\\Theming\\ImageManager' => $baseDir.'/../lib/ImageManager.php',
20
+    'OCA\\Theming\\Jobs\\MigrateBackgroundImages' => $baseDir.'/../lib/Jobs/MigrateBackgroundImages.php',
21
+    'OCA\\Theming\\Jobs\\RestoreBackgroundImageColor' => $baseDir.'/../lib/Jobs/RestoreBackgroundImageColor.php',
22
+    'OCA\\Theming\\Listener\\BeforePreferenceListener' => $baseDir.'/../lib/Listener/BeforePreferenceListener.php',
23
+    'OCA\\Theming\\Listener\\BeforeTemplateRenderedListener' => $baseDir.'/../lib/Listener/BeforeTemplateRenderedListener.php',
24
+    'OCA\\Theming\\Migration\\InitBackgroundImagesMigration' => $baseDir.'/../lib/Migration/InitBackgroundImagesMigration.php',
25
+    'OCA\\Theming\\Migration\\Version2006Date20240905111627' => $baseDir.'/../lib/Migration/Version2006Date20240905111627.php',
26
+    'OCA\\Theming\\ResponseDefinitions' => $baseDir.'/../lib/ResponseDefinitions.php',
27
+    'OCA\\Theming\\Service\\BackgroundService' => $baseDir.'/../lib/Service/BackgroundService.php',
28
+    'OCA\\Theming\\Service\\JSDataService' => $baseDir.'/../lib/Service/JSDataService.php',
29
+    'OCA\\Theming\\Service\\ThemeInjectionService' => $baseDir.'/../lib/Service/ThemeInjectionService.php',
30
+    'OCA\\Theming\\Service\\ThemesService' => $baseDir.'/../lib/Service/ThemesService.php',
31
+    'OCA\\Theming\\Settings\\Admin' => $baseDir.'/../lib/Settings/Admin.php',
32
+    'OCA\\Theming\\Settings\\AdminSection' => $baseDir.'/../lib/Settings/AdminSection.php',
33
+    'OCA\\Theming\\Settings\\Personal' => $baseDir.'/../lib/Settings/Personal.php',
34
+    'OCA\\Theming\\Settings\\PersonalSection' => $baseDir.'/../lib/Settings/PersonalSection.php',
35
+    'OCA\\Theming\\SetupChecks\\PhpImagickModule' => $baseDir.'/../lib/SetupChecks/PhpImagickModule.php',
36
+    'OCA\\Theming\\Themes\\CommonThemeTrait' => $baseDir.'/../lib/Themes/CommonThemeTrait.php',
37
+    'OCA\\Theming\\Themes\\DarkHighContrastTheme' => $baseDir.'/../lib/Themes/DarkHighContrastTheme.php',
38
+    'OCA\\Theming\\Themes\\DarkTheme' => $baseDir.'/../lib/Themes/DarkTheme.php',
39
+    'OCA\\Theming\\Themes\\DefaultTheme' => $baseDir.'/../lib/Themes/DefaultTheme.php',
40
+    'OCA\\Theming\\Themes\\DyslexiaFont' => $baseDir.'/../lib/Themes/DyslexiaFont.php',
41
+    'OCA\\Theming\\Themes\\HighContrastTheme' => $baseDir.'/../lib/Themes/HighContrastTheme.php',
42
+    'OCA\\Theming\\Themes\\LightTheme' => $baseDir.'/../lib/Themes/LightTheme.php',
43
+    'OCA\\Theming\\ThemingDefaults' => $baseDir.'/../lib/ThemingDefaults.php',
44
+    'OCA\\Theming\\Util' => $baseDir.'/../lib/Util.php',
45 45
 );
Please login to merge, or discard this patch.
apps/theming/tests/ThemingDefaultsTest.php 2 patches
Indentation   +799 added lines, -799 removed lines patch added patch discarded remove patch
@@ -26,803 +26,803 @@
 block discarded – undo
26 26
 use Test\TestCase;
27 27
 
28 28
 class ThemingDefaultsTest extends TestCase {
29
-	private IAppConfig&MockObject $appConfig;
30
-	private IConfig&MockObject $config;
31
-	private IL10N&MockObject $l10n;
32
-	private IUserSession&MockObject $userSession;
33
-	private IURLGenerator&MockObject $urlGenerator;
34
-	private ICacheFactory&MockObject $cacheFactory;
35
-	private Util&MockObject $util;
36
-	private ICache&MockObject $cache;
37
-	private IAppManager&MockObject $appManager;
38
-	private ImageManager&MockObject $imageManager;
39
-	private INavigationManager&MockObject $navigationManager;
40
-	private BackgroundService&MockObject $backgroundService;
41
-
42
-	private \OC_Defaults $defaults;
43
-	private ThemingDefaults $template;
44
-
45
-	protected function setUp(): void {
46
-		parent::setUp();
47
-		$this->appConfig = $this->createMock(IAppConfig::class);
48
-		$this->config = $this->createMock(IConfig::class);
49
-		$this->l10n = $this->createMock(IL10N::class);
50
-		$this->userSession = $this->createMock(IUserSession::class);
51
-		$this->urlGenerator = $this->createMock(IURLGenerator::class);
52
-		$this->cacheFactory = $this->createMock(ICacheFactory::class);
53
-		$this->cache = $this->createMock(ICache::class);
54
-		$this->util = $this->createMock(Util::class);
55
-		$this->imageManager = $this->createMock(ImageManager::class);
56
-		$this->appManager = $this->createMock(IAppManager::class);
57
-		$this->navigationManager = $this->createMock(INavigationManager::class);
58
-		$this->backgroundService = $this->createMock(BackgroundService::class);
59
-		$this->defaults = new \OC_Defaults();
60
-		$this->urlGenerator
61
-			->expects($this->any())
62
-			->method('getBaseUrl')
63
-			->willReturn('');
64
-		$this->template = new ThemingDefaults(
65
-			$this->config,
66
-			$this->appConfig,
67
-			$this->l10n,
68
-			$this->userSession,
69
-			$this->urlGenerator,
70
-			$this->cacheFactory,
71
-			$this->util,
72
-			$this->imageManager,
73
-			$this->appManager,
74
-			$this->navigationManager,
75
-			$this->backgroundService,
76
-		);
77
-	}
78
-
79
-	public function testGetNameWithDefault(): void {
80
-		$this->appConfig
81
-			->expects($this->once())
82
-			->method('getAppValueString')
83
-			->with('name', 'Nextcloud')
84
-			->willReturn('Nextcloud');
85
-
86
-		$this->assertEquals('Nextcloud', $this->template->getName());
87
-	}
88
-
89
-	public function testGetNameWithCustom(): void {
90
-		$this->appConfig
91
-			->expects($this->once())
92
-			->method('getAppValueString')
93
-			->with('name', 'Nextcloud')
94
-			->willReturn('MyCustomCloud');
95
-
96
-		$this->assertEquals('MyCustomCloud', $this->template->getName());
97
-	}
98
-
99
-	public function testGetHTMLNameWithDefault(): void {
100
-		$this->appConfig
101
-			->expects($this->once())
102
-			->method('getAppValueString')
103
-			->with('name', 'Nextcloud')
104
-			->willReturn('Nextcloud');
105
-
106
-		$this->assertEquals('Nextcloud', $this->template->getHTMLName());
107
-	}
108
-
109
-	public function testGetHTMLNameWithCustom(): void {
110
-		$this->appConfig
111
-			->expects($this->once())
112
-			->method('getAppValueString')
113
-			->with('name', 'Nextcloud')
114
-			->willReturn('MyCustomCloud');
115
-
116
-		$this->assertEquals('MyCustomCloud', $this->template->getHTMLName());
117
-	}
118
-
119
-	public function testGetTitleWithDefault(): void {
120
-		$this->appConfig
121
-			->expects($this->once())
122
-			->method('getAppValueString')
123
-			->with('name', 'Nextcloud')
124
-			->willReturn('Nextcloud');
125
-
126
-		$this->assertEquals('Nextcloud', $this->template->getTitle());
127
-	}
128
-
129
-	public function testGetTitleWithCustom(): void {
130
-		$this->appConfig
131
-			->expects($this->once())
132
-			->method('getAppValueString')
133
-			->with('name', 'Nextcloud')
134
-			->willReturn('MyCustomCloud');
135
-
136
-		$this->assertEquals('MyCustomCloud', $this->template->getTitle());
137
-	}
138
-
139
-
140
-	public function testGetEntityWithDefault(): void {
141
-		$this->appConfig
142
-			->expects($this->once())
143
-			->method('getAppValueString')
144
-			->with('name', 'Nextcloud')
145
-			->willReturn('Nextcloud');
146
-
147
-		$this->assertEquals('Nextcloud', $this->template->getEntity());
148
-	}
149
-
150
-	public function testGetEntityWithCustom(): void {
151
-		$this->appConfig
152
-			->expects($this->once())
153
-			->method('getAppValueString')
154
-			->with('name', 'Nextcloud')
155
-			->willReturn('MyCustomCloud');
156
-
157
-		$this->assertEquals('MyCustomCloud', $this->template->getEntity());
158
-	}
159
-
160
-	public function testGetBaseUrlWithDefault(): void {
161
-		$this->appConfig
162
-			->expects($this->once())
163
-			->method('getAppValueString')
164
-			->with('url', $this->defaults->getBaseUrl())
165
-			->willReturn($this->defaults->getBaseUrl());
166
-
167
-		$this->assertEquals($this->defaults->getBaseUrl(), $this->template->getBaseUrl());
168
-	}
169
-
170
-	public function testGetBaseUrlWithCustom(): void {
171
-		$this->appConfig
172
-			->expects($this->once())
173
-			->method('getAppValueString')
174
-			->with('url', $this->defaults->getBaseUrl())
175
-			->willReturn('https://example.com/');
176
-
177
-		$this->assertEquals('https://example.com/', $this->template->getBaseUrl());
178
-	}
179
-
180
-	public static function legalUrlProvider(): array {
181
-		return [
182
-			[''],
183
-			['https://example.com/legal.html'],
184
-		];
185
-	}
186
-
187
-	#[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')]
188
-	public function testGetImprintURL(string $imprintUrl): void {
189
-		$this->appConfig
190
-			->expects($this->once())
191
-			->method('getAppValueString')
192
-			->with('imprintUrl', '')
193
-			->willReturn($imprintUrl);
194
-
195
-		$this->assertEquals($imprintUrl, $this->template->getImprintUrl());
196
-	}
197
-
198
-	#[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')]
199
-	public function testGetPrivacyURL(string $privacyUrl): void {
200
-		$this->appConfig
201
-			->expects($this->once())
202
-			->method('getAppValueString')
203
-			->with('privacyUrl', '')
204
-			->willReturn($privacyUrl);
205
-
206
-		$this->assertEquals($privacyUrl, $this->template->getPrivacyUrl());
207
-	}
208
-
209
-	public function testGetSloganWithDefault(): void {
210
-		$this->appConfig
211
-			->expects($this->once())
212
-			->method('getAppValueString')
213
-			->with('slogan', $this->defaults->getSlogan())
214
-			->willReturn($this->defaults->getSlogan());
215
-
216
-		$this->assertEquals($this->defaults->getSlogan(), $this->template->getSlogan());
217
-	}
218
-
219
-	public function testGetSloganWithCustom(): void {
220
-		$this->appConfig
221
-			->expects($this->once())
222
-			->method('getAppValueString')
223
-			->with('slogan', $this->defaults->getSlogan())
224
-			->willReturn('My custom Slogan');
225
-
226
-		$this->assertEquals('My custom Slogan', $this->template->getSlogan());
227
-	}
228
-
229
-	public function testGetShortFooter(): void {
230
-		$this->appConfig
231
-			->expects($this->exactly(5))
232
-			->method('getAppValueString')
233
-			->willReturnMap([
234
-				['url', $this->defaults->getBaseUrl(), 'url'],
235
-				['name', 'Nextcloud', 'Name'],
236
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
237
-				['imprintUrl', '', ''],
238
-				['privacyUrl', '', ''],
239
-			]);
240
-
241
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
242
-	}
243
-
244
-	public function testGetShortFooterEmptyUrl(): void {
245
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
246
-		$this->appConfig
247
-			->expects($this->exactly(5))
248
-			->method('getAppValueString')
249
-			->willReturnMap([
250
-				['url', $this->defaults->getBaseUrl(), ''],
251
-				['name', 'Nextcloud', 'Name'],
252
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
253
-				['imprintUrl', '', ''],
254
-				['privacyUrl', '', ''],
255
-			]);
256
-
257
-		$this->assertEquals('<span class="entity-name">Name</span> – Slogan', $this->template->getShortFooter());
258
-	}
259
-
260
-	public function testGetShortFooterEmptySlogan(): void {
261
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
262
-		$this->appConfig
263
-			->expects($this->exactly(5))
264
-			->method('getAppValueString')
265
-			->willReturnMap([
266
-				['url', $this->defaults->getBaseUrl(), 'url'],
267
-				['name', 'Nextcloud', 'Name'],
268
-				['slogan', $this->defaults->getSlogan(), ''],
269
-				['imprintUrl', '', ''],
270
-				['privacyUrl', '', ''],
271
-			]);
272
-
273
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a>', $this->template->getShortFooter());
274
-	}
275
-
276
-	public function testGetShortFooterImprint(): void {
277
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
278
-		$this->appConfig
279
-			->expects($this->exactly(5))
280
-			->method('getAppValueString')
281
-			->willReturnMap([
282
-				['url', $this->defaults->getBaseUrl(), 'url'],
283
-				['name', 'Nextcloud', 'Name'],
284
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
285
-				['imprintUrl', '', 'https://example.com/imprint'],
286
-				['privacyUrl', '', ''],
287
-			]);
288
-
289
-		$this->l10n
290
-			->expects($this->any())
291
-			->method('t')
292
-			->willReturnArgument(0);
293
-
294
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a></span>', $this->template->getShortFooter());
295
-	}
296
-
297
-	public function testGetShortFooterPrivacy(): void {
298
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
299
-		$this->appConfig
300
-			->expects($this->exactly(5))
301
-			->method('getAppValueString')
302
-			->willReturnMap([
303
-				['url', $this->defaults->getBaseUrl(), 'url'],
304
-				['name', 'Nextcloud', 'Name'],
305
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
306
-				['imprintUrl', '', ''],
307
-				['privacyUrl', '', 'https://example.com/privacy'],
308
-			]);
309
-
310
-		$this->l10n
311
-			->expects($this->any())
312
-			->method('t')
313
-			->willReturnArgument(0);
314
-
315
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a></span>', $this->template->getShortFooter());
316
-	}
317
-
318
-	public function testGetShortFooterAllLegalLinks(): void {
319
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
320
-		$this->appConfig
321
-			->expects($this->exactly(5))
322
-			->method('getAppValueString')
323
-			->willReturnMap([
324
-				['url', $this->defaults->getBaseUrl(), 'url'],
325
-				['name', 'Nextcloud', 'Name'],
326
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
327
-				['imprintUrl', '', 'https://example.com/imprint'],
328
-				['privacyUrl', '', 'https://example.com/privacy'],
329
-			]);
330
-
331
-		$this->l10n
332
-			->expects($this->any())
333
-			->method('t')
334
-			->willReturnArgument(0);
335
-
336
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a> · <a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a></span>', $this->template->getShortFooter());
337
-	}
338
-
339
-	public static function invalidLegalUrlProvider(): array {
340
-		return [
341
-			['example.com/legal'],  # missing scheme
342
-			['https:///legal'],     # missing host
343
-		];
344
-	}
345
-
346
-	#[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')]
347
-	public function testGetShortFooterInvalidImprint(string $invalidImprintUrl): void {
348
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
349
-		$this->appConfig
350
-			->expects($this->exactly(5))
351
-			->method('getAppValueString')
352
-			->willReturnMap([
353
-				['url', $this->defaults->getBaseUrl(), 'url'],
354
-				['name', 'Nextcloud', 'Name'],
355
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
356
-				['imprintUrl', '', $invalidImprintUrl],
357
-				['privacyUrl', '', ''],
358
-			]);
359
-
360
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
361
-	}
362
-
363
-	#[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')]
364
-	public function testGetShortFooterInvalidPrivacy(string $invalidPrivacyUrl): void {
365
-		$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
366
-		$this->appConfig
367
-			->expects($this->exactly(5))
368
-			->method('getAppValueString')
369
-			->willReturnMap([
370
-				['url', $this->defaults->getBaseUrl(), 'url'],
371
-				['name', 'Nextcloud', 'Name'],
372
-				['slogan', $this->defaults->getSlogan(), 'Slogan'],
373
-				['imprintUrl', '', ''],
374
-				['privacyUrl', '', $invalidPrivacyUrl],
375
-			]);
376
-
377
-		$this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
378
-	}
379
-
380
-	public function testGetColorPrimaryWithDefault(): void {
381
-		$this->appConfig
382
-			->expects(self::once())
383
-			->method('getAppValueBool')
384
-			->with('disable-user-theming')
385
-			->willReturn(false);
386
-		$this->appConfig
387
-			->expects(self::once())
388
-			->method('getAppValueString')
389
-			->with('primary_color', '')
390
-			->willReturn($this->defaults->getColorPrimary());
391
-
392
-		$this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
393
-	}
394
-
395
-	public function testGetColorPrimaryWithCustom(): void {
396
-		$this->appConfig
397
-			->expects(self::once())
398
-			->method('getAppValueBool')
399
-			->with('disable-user-theming')
400
-			->willReturn(false);
401
-		$this->appConfig
402
-			->expects(self::once())
403
-			->method('getAppValueString')
404
-			->with('primary_color', '')
405
-			->willReturn('#fff');
406
-
407
-		$this->assertEquals('#fff', $this->template->getColorPrimary());
408
-	}
409
-
410
-	public static function dataGetColorPrimary(): array {
411
-		return [
412
-			'with fallback default' => [
413
-				'disableTheming' => false,
414
-				'primaryColor' => '',
415
-				'userPrimaryColor' => '',
416
-				'expected' => BackgroundService::DEFAULT_COLOR,
417
-			],
418
-			'with custom admin primary' => [
419
-				'disableTheming' => false,
420
-				'primaryColor' => '#aaa',
421
-				'userPrimaryColor' => '',
422
-				'expected' => '#aaa',
423
-			],
424
-			'with custom invalid admin primary' => [
425
-				'disableTheming' => false,
426
-				'primaryColor' => 'invalid',
427
-				'userPrimaryColor' => '',
428
-				'expected' => BackgroundService::DEFAULT_COLOR,
429
-			],
430
-			'with custom invalid user primary' => [
431
-				'disableTheming' => false,
432
-				'primaryColor' => '',
433
-				'userPrimaryColor' => 'invalid-name',
434
-				'expected' => BackgroundService::DEFAULT_COLOR,
435
-			],
436
-			'with custom user primary' => [
437
-				'disableTheming' => false,
438
-				'primaryColor' => '',
439
-				'userPrimaryColor' => '#bbb',
440
-				'expected' => '#bbb',
441
-			],
442
-			'with disabled user theming primary' => [
443
-				'disableTheming' => true,
444
-				'primaryColor' => '#aaa',
445
-				'userPrimaryColor' => '#bbb',
446
-				'expected' => '#aaa',
447
-			],
448
-		];
449
-	}
450
-
451
-	#[\PHPUnit\Framework\Attributes\DataProvider('dataGetColorPrimary')]
452
-	public function testGetColorPrimary(bool $disableTheming, string $primaryColor, string $userPrimaryColor, string $expected): void {
453
-		$user = $this->createMock(IUser::class);
454
-		$this->userSession->expects($this->any())
455
-			->method('getUser')
456
-			->willReturn($user);
457
-		$user->expects($this->any())
458
-			->method('getUID')
459
-			->willReturn('user');
460
-		$this->appConfig
461
-			->expects(self::any())
462
-			->method('getAppValueBool')
463
-			->with('disable-user-theming')
464
-			->willReturn($disableTheming);
465
-		$this->appConfig
466
-			->expects(self::any())
467
-			->method('getAppValueString')
468
-			->with('primary_color', '')
469
-			->willReturn($primaryColor);
470
-		$this->config
471
-			->expects($this->any())
472
-			->method('getUserValue')
473
-			->with('user', 'theming', 'primary_color', '')
474
-			->willReturn($userPrimaryColor);
475
-
476
-		$this->assertEquals($expected, $this->template->getColorPrimary());
477
-	}
478
-
479
-	public function testSet(): void {
480
-		$this->appConfig
481
-			->expects($this->once())
482
-			->method('setAppValueInt')
483
-			->with('cachebuster', 16);
484
-		$this->appConfig
485
-			->expects($this->once())
486
-			->method('setAppValueString')
487
-			->with('MySetting', 'MyValue');
488
-		$this->appConfig
489
-			->expects($this->once())
490
-			->method('getAppValueInt')
491
-			->with('cachebuster')
492
-			->willReturn(15);
493
-		$this->cacheFactory
494
-			->expects($this->exactly(2))
495
-			->method('createDistributed')
496
-			->willReturnMap([
497
-				['theming-', $this->cache],
498
-				['imagePath', $this->cache],
499
-			]);
500
-		$this->cache
501
-			->expects($this->any())
502
-			->method('clear')
503
-			->with('');
504
-		$this->template->set('MySetting', 'MyValue');
505
-	}
506
-
507
-	public function testUndoName(): void {
508
-		$this->appConfig
509
-			->expects($this->once())
510
-			->method('deleteAppValue')
511
-			->with('name');
512
-		$this->appConfig
513
-			->expects($this->once())
514
-			->method('getAppValueInt')
515
-			->with('cachebuster')
516
-			->willReturn(15);
517
-		$this->appConfig
518
-			->expects($this->once())
519
-			->method('getAppValueString')
520
-			->with('name', 'Nextcloud')
521
-			->willReturn('Nextcloud');
522
-		$this->appConfig
523
-			->expects($this->once())
524
-			->method('setAppValueInt')
525
-			->with('cachebuster', 16);
526
-
527
-		$this->assertSame('Nextcloud', $this->template->undo('name'));
528
-	}
529
-
530
-	public function testUndoBaseUrl(): void {
531
-		$this->appConfig
532
-			->expects($this->once())
533
-			->method('deleteAppValue')
534
-			->with('url');
535
-		$this->appConfig
536
-			->expects($this->once())
537
-			->method('getAppValueInt')
538
-			->with('cachebuster')
539
-			->willReturn(15);
540
-		$this->appConfig
541
-			->expects($this->once())
542
-			->method('getAppValueString')
543
-			->with('url', $this->defaults->getBaseUrl())
544
-			->willReturn($this->defaults->getBaseUrl());
545
-		$this->appConfig
546
-			->expects($this->once())
547
-			->method('setAppValueInt')
548
-			->with('cachebuster', 16);
549
-
550
-		$this->assertSame($this->defaults->getBaseUrl(), $this->template->undo('url'));
551
-	}
552
-
553
-	public function testUndoSlogan(): void {
554
-		$this->appConfig
555
-			->expects($this->once())
556
-			->method('deleteAppValue')
557
-			->with('slogan');
558
-		$this->appConfig
559
-			->expects($this->once())
560
-			->method('getAppValueInt')
561
-			->with('cachebuster')
562
-			->willReturn(15);
563
-		$this->appConfig
564
-			->expects($this->once())
565
-			->method('getAppValueString')
566
-			->with('slogan', $this->defaults->getSlogan())
567
-			->willReturn($this->defaults->getSlogan());
568
-		$this->appConfig
569
-			->expects($this->once())
570
-			->method('setAppValueInt')
571
-			->with('cachebuster', 16);
572
-
573
-		$this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
574
-	}
575
-
576
-	public function testUndoPrimaryColor(): void {
577
-		$this->appConfig
578
-			->expects($this->once())
579
-			->method('deleteAppValue')
580
-			->with('primary_color');
581
-		$this->appConfig
582
-			->expects($this->once())
583
-			->method('getAppValueInt')
584
-			->with('cachebuster')
585
-			->willReturn(15);
586
-		$this->appConfig
587
-			->expects($this->once())
588
-			->method('setAppValueInt')
589
-			->with('cachebuster', 16);
590
-
591
-		$this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('primary_color'));
592
-	}
593
-
594
-	public function testUndoDefaultAction(): void {
595
-		$this->appConfig
596
-			->expects($this->once())
597
-			->method('deleteAppValue')
598
-			->with('defaultitem');
599
-		$this->appConfig
600
-			->expects($this->once())
601
-			->method('getAppValueInt')
602
-			->with('cachebuster', '0')
603
-			->willReturn(15);
604
-		$this->appConfig
605
-			->expects($this->once())
606
-			->method('setAppValueInt')
607
-			->with('cachebuster', 16);
608
-
609
-		$this->assertSame('', $this->template->undo('defaultitem'));
610
-	}
611
-
612
-	public function testGetBackground(): void {
613
-		$this->imageManager
614
-			->expects($this->once())
615
-			->method('getImageUrl')
616
-			->with('background')
617
-			->willReturn('custom-background?v=0');
618
-		$this->assertEquals('custom-background?v=0', $this->template->getBackground());
619
-	}
620
-
621
-	private function getLogoHelper($withName, $useSvg) {
622
-		$this->imageManager->expects($this->any())
623
-			->method('getImage')
624
-			->with('logo')
625
-			->willThrowException(new NotFoundException());
626
-		$this->appConfig
627
-			->expects($this->once())
628
-			->method('getAppValueString')
629
-			->with('logoMime', '')
630
-			->willReturn('');
631
-		$this->appConfig
632
-			->expects($this->once())
633
-			->method('getAppValueInt')
634
-			->with('cachebuster')
635
-			->willReturn(0);
636
-		$this->urlGenerator->expects($this->once())
637
-			->method('imagePath')
638
-			->with('core', $withName)
639
-			->willReturn('core-logo');
640
-		$this->assertEquals('core-logo?v=0', $this->template->getLogo($useSvg));
641
-	}
642
-
643
-	public function testGetLogoDefaultWithSvg(): void {
644
-		$this->getLogoHelper('logo/logo.svg', true);
645
-	}
646
-
647
-	public function testGetLogoDefaultWithoutSvg(): void {
648
-		$this->getLogoHelper('logo/logo.png', false);
649
-	}
650
-
651
-	public function testGetLogoCustom(): void {
652
-		$this->appConfig
653
-			->expects($this->once())
654
-			->method('getAppValueString')
655
-			->with('logoMime', '')
656
-			->willReturn('image/svg+xml');
657
-		$this->appConfig
658
-			->expects($this->once())
659
-			->method('getAppValueInt')
660
-			->with('cachebuster')
661
-			->willReturn(0);
662
-		$this->urlGenerator->expects($this->once())
663
-			->method('linkToRoute')
664
-			->with('theming.Theming.getImage')
665
-			->willReturn('custom-logo?v=0');
666
-		$this->assertEquals('custom-logo' . '?v=0', $this->template->getLogo());
667
-	}
668
-
669
-	public function testGetScssVariablesCached(): void {
670
-		$this->appConfig->expects($this->any())
671
-			->method('getAppValueInt')
672
-			->with('cachebuster')
673
-			->willReturn(1);
674
-		$this->cacheFactory->expects($this->once())
675
-			->method('createDistributed')
676
-			->with('theming-1-')
677
-			->willReturn($this->cache);
678
-		$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo' => 'bar']);
679
-		$this->assertEquals(['foo' => 'bar'], $this->template->getScssVariables());
680
-	}
681
-
682
-	public function testGetScssVariables(): void {
683
-		$this->appConfig->expects($this->any())
684
-			->method('getAppValueInt')
685
-			->with('cachebuster')
686
-			->willReturn(0);
687
-		$this->appConfig
688
-			->expects($this->any())
689
-			->method('getAppValueString')
690
-			->willReturnMap([
691
-				['imprintUrl', '', ''],
692
-				['privacyUrl', '', ''],
693
-				['logoMime', '', 'jpeg'],
694
-				['backgroundMime', '', 'jpeg'],
695
-				['logoheaderMime', '', 'jpeg'],
696
-				['faviconMime', '', 'jpeg'],
697
-				['primary_color', '', false, $this->defaults->getColorPrimary()],
698
-				['primary_color', $this->defaults->getColorPrimary(), false, $this->defaults->getColorPrimary()],
699
-			]);
700
-
701
-		$this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
702
-		$this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
703
-		$this->cacheFactory->expects($this->once())
704
-			->method('createDistributed')
705
-			->with('theming-0-')
706
-			->willReturn($this->cache);
707
-		$this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
708
-		$this->imageManager->expects($this->exactly(4))
709
-			->method('getImageUrl')
710
-			->willReturnMap([
711
-				['logo', 'custom-logo?v=0'],
712
-				['logoheader', 'custom-logoheader?v=0'],
713
-				['favicon', 'custom-favicon?v=0'],
714
-				['background', 'custom-background?v=0'],
715
-			]);
716
-
717
-		$expected = [
718
-			'theming-cachebuster' => '\'0\'',
719
-			'theming-logo-mime' => '\'jpeg\'',
720
-			'theming-background-mime' => '\'jpeg\'',
721
-			'image-logo' => "url('custom-logo?v=0')",
722
-			'image-login-background' => "url('custom-background?v=0')",
723
-			'color-primary' => $this->defaults->getColorPrimary(),
724
-			'color-primary-text' => '#ffffff',
725
-			'image-login-plain' => 'false',
726
-			'color-primary-element' => '#aaaaaa',
727
-			'theming-logoheader-mime' => '\'jpeg\'',
728
-			'theming-favicon-mime' => '\'jpeg\'',
729
-			'image-logoheader' => "url('custom-logoheader?v=0')",
730
-			'image-favicon' => "url('custom-favicon?v=0')",
731
-			'has-legal-links' => 'false'
732
-		];
733
-		$this->assertEquals($expected, $this->template->getScssVariables());
734
-	}
735
-
736
-	public function testGetDefaultAndroidURL(): void {
737
-		$this->appConfig
738
-			->expects($this->once())
739
-			->method('getAppValueString')
740
-			->with('AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
741
-			->willReturn('https://play.google.com/store/apps/details?id=com.nextcloud.client');
742
-
743
-		$this->assertEquals('https://play.google.com/store/apps/details?id=com.nextcloud.client', $this->template->getAndroidClientUrl());
744
-	}
745
-
746
-	public function testGetCustomAndroidURL(): void {
747
-		$this->appConfig
748
-			->expects($this->once())
749
-			->method('getAppValueString')
750
-			->with('AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
751
-			->willReturn('https://play.google.com/store/apps/details?id=com.mycloud.client');
752
-
753
-		$this->assertEquals('https://play.google.com/store/apps/details?id=com.mycloud.client', $this->template->getAndroidClientUrl());
754
-	}
755
-
756
-	public function testGetDefaultiOSURL(): void {
757
-		$this->appConfig
758
-			->expects($this->once())
759
-			->method('getAppValueString')
760
-			->with('iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
761
-			->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
762
-
763
-		$this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', $this->template->getiOSClientUrl());
764
-	}
765
-
766
-	public function testGetCustomiOSURL(): void {
767
-		$this->appConfig
768
-			->expects($this->once())
769
-			->method('getAppValueString')
770
-			->with('iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
771
-			->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8');
772
-
773
-		$this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8', $this->template->getiOSClientUrl());
774
-	}
775
-
776
-	public function testGetDefaultiTunesAppId(): void {
777
-		$this->appConfig
778
-			->expects($this->once())
779
-			->method('getAppValueString')
780
-			->with('iTunesAppId', '1125420102')
781
-			->willReturn('1125420102');
782
-
783
-		$this->assertEquals('1125420102', $this->template->getiTunesAppId());
784
-	}
785
-
786
-	public function testGetCustomiTunesAppId(): void {
787
-		$this->appConfig
788
-			->expects($this->once())
789
-			->method('getAppValueString')
790
-			->with('iTunesAppId', '1125420102')
791
-			->willReturn('1234567890');
792
-
793
-		$this->assertEquals('1234567890', $this->template->getiTunesAppId());
794
-	}
795
-
796
-	public static function dataReplaceImagePath(): array {
797
-		return [
798
-			['core', 'test.png', false],
799
-			['core', 'manifest.json'],
800
-			['core', 'favicon.ico'],
801
-			['core', 'favicon-touch.png']
802
-		];
803
-	}
804
-
805
-	#[\PHPUnit\Framework\Attributes\DataProvider('dataReplaceImagePath')]
806
-	public function testReplaceImagePath(string $app, string $image, string|bool $result = 'themingRoute?v=1234abcd'): void {
807
-		$this->cache->expects($this->any())
808
-			->method('get')
809
-			->with('shouldReplaceIcons')
810
-			->willReturn(true);
811
-		$this->appConfig
812
-			->expects($this->any())
813
-			->method('getAppValueInt')
814
-			->with('cachebuster')
815
-			->willReturn(0);
816
-		$this->urlGenerator
817
-			->expects($this->any())
818
-			->method('linkToRoute')
819
-			->willReturn('themingRoute');
820
-		if ($result) {
821
-			$this->util
822
-				->expects($this->once())
823
-				->method('getCacheBuster')
824
-				->willReturn('1234abcd');
825
-		}
826
-		$this->assertEquals($result, $this->template->replaceImagePath($app, $image));
827
-	}
29
+    private IAppConfig&MockObject $appConfig;
30
+    private IConfig&MockObject $config;
31
+    private IL10N&MockObject $l10n;
32
+    private IUserSession&MockObject $userSession;
33
+    private IURLGenerator&MockObject $urlGenerator;
34
+    private ICacheFactory&MockObject $cacheFactory;
35
+    private Util&MockObject $util;
36
+    private ICache&MockObject $cache;
37
+    private IAppManager&MockObject $appManager;
38
+    private ImageManager&MockObject $imageManager;
39
+    private INavigationManager&MockObject $navigationManager;
40
+    private BackgroundService&MockObject $backgroundService;
41
+
42
+    private \OC_Defaults $defaults;
43
+    private ThemingDefaults $template;
44
+
45
+    protected function setUp(): void {
46
+        parent::setUp();
47
+        $this->appConfig = $this->createMock(IAppConfig::class);
48
+        $this->config = $this->createMock(IConfig::class);
49
+        $this->l10n = $this->createMock(IL10N::class);
50
+        $this->userSession = $this->createMock(IUserSession::class);
51
+        $this->urlGenerator = $this->createMock(IURLGenerator::class);
52
+        $this->cacheFactory = $this->createMock(ICacheFactory::class);
53
+        $this->cache = $this->createMock(ICache::class);
54
+        $this->util = $this->createMock(Util::class);
55
+        $this->imageManager = $this->createMock(ImageManager::class);
56
+        $this->appManager = $this->createMock(IAppManager::class);
57
+        $this->navigationManager = $this->createMock(INavigationManager::class);
58
+        $this->backgroundService = $this->createMock(BackgroundService::class);
59
+        $this->defaults = new \OC_Defaults();
60
+        $this->urlGenerator
61
+            ->expects($this->any())
62
+            ->method('getBaseUrl')
63
+            ->willReturn('');
64
+        $this->template = new ThemingDefaults(
65
+            $this->config,
66
+            $this->appConfig,
67
+            $this->l10n,
68
+            $this->userSession,
69
+            $this->urlGenerator,
70
+            $this->cacheFactory,
71
+            $this->util,
72
+            $this->imageManager,
73
+            $this->appManager,
74
+            $this->navigationManager,
75
+            $this->backgroundService,
76
+        );
77
+    }
78
+
79
+    public function testGetNameWithDefault(): void {
80
+        $this->appConfig
81
+            ->expects($this->once())
82
+            ->method('getAppValueString')
83
+            ->with('name', 'Nextcloud')
84
+            ->willReturn('Nextcloud');
85
+
86
+        $this->assertEquals('Nextcloud', $this->template->getName());
87
+    }
88
+
89
+    public function testGetNameWithCustom(): void {
90
+        $this->appConfig
91
+            ->expects($this->once())
92
+            ->method('getAppValueString')
93
+            ->with('name', 'Nextcloud')
94
+            ->willReturn('MyCustomCloud');
95
+
96
+        $this->assertEquals('MyCustomCloud', $this->template->getName());
97
+    }
98
+
99
+    public function testGetHTMLNameWithDefault(): void {
100
+        $this->appConfig
101
+            ->expects($this->once())
102
+            ->method('getAppValueString')
103
+            ->with('name', 'Nextcloud')
104
+            ->willReturn('Nextcloud');
105
+
106
+        $this->assertEquals('Nextcloud', $this->template->getHTMLName());
107
+    }
108
+
109
+    public function testGetHTMLNameWithCustom(): void {
110
+        $this->appConfig
111
+            ->expects($this->once())
112
+            ->method('getAppValueString')
113
+            ->with('name', 'Nextcloud')
114
+            ->willReturn('MyCustomCloud');
115
+
116
+        $this->assertEquals('MyCustomCloud', $this->template->getHTMLName());
117
+    }
118
+
119
+    public function testGetTitleWithDefault(): void {
120
+        $this->appConfig
121
+            ->expects($this->once())
122
+            ->method('getAppValueString')
123
+            ->with('name', 'Nextcloud')
124
+            ->willReturn('Nextcloud');
125
+
126
+        $this->assertEquals('Nextcloud', $this->template->getTitle());
127
+    }
128
+
129
+    public function testGetTitleWithCustom(): void {
130
+        $this->appConfig
131
+            ->expects($this->once())
132
+            ->method('getAppValueString')
133
+            ->with('name', 'Nextcloud')
134
+            ->willReturn('MyCustomCloud');
135
+
136
+        $this->assertEquals('MyCustomCloud', $this->template->getTitle());
137
+    }
138
+
139
+
140
+    public function testGetEntityWithDefault(): void {
141
+        $this->appConfig
142
+            ->expects($this->once())
143
+            ->method('getAppValueString')
144
+            ->with('name', 'Nextcloud')
145
+            ->willReturn('Nextcloud');
146
+
147
+        $this->assertEquals('Nextcloud', $this->template->getEntity());
148
+    }
149
+
150
+    public function testGetEntityWithCustom(): void {
151
+        $this->appConfig
152
+            ->expects($this->once())
153
+            ->method('getAppValueString')
154
+            ->with('name', 'Nextcloud')
155
+            ->willReturn('MyCustomCloud');
156
+
157
+        $this->assertEquals('MyCustomCloud', $this->template->getEntity());
158
+    }
159
+
160
+    public function testGetBaseUrlWithDefault(): void {
161
+        $this->appConfig
162
+            ->expects($this->once())
163
+            ->method('getAppValueString')
164
+            ->with('url', $this->defaults->getBaseUrl())
165
+            ->willReturn($this->defaults->getBaseUrl());
166
+
167
+        $this->assertEquals($this->defaults->getBaseUrl(), $this->template->getBaseUrl());
168
+    }
169
+
170
+    public function testGetBaseUrlWithCustom(): void {
171
+        $this->appConfig
172
+            ->expects($this->once())
173
+            ->method('getAppValueString')
174
+            ->with('url', $this->defaults->getBaseUrl())
175
+            ->willReturn('https://example.com/');
176
+
177
+        $this->assertEquals('https://example.com/', $this->template->getBaseUrl());
178
+    }
179
+
180
+    public static function legalUrlProvider(): array {
181
+        return [
182
+            [''],
183
+            ['https://example.com/legal.html'],
184
+        ];
185
+    }
186
+
187
+    #[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')]
188
+    public function testGetImprintURL(string $imprintUrl): void {
189
+        $this->appConfig
190
+            ->expects($this->once())
191
+            ->method('getAppValueString')
192
+            ->with('imprintUrl', '')
193
+            ->willReturn($imprintUrl);
194
+
195
+        $this->assertEquals($imprintUrl, $this->template->getImprintUrl());
196
+    }
197
+
198
+    #[\PHPUnit\Framework\Attributes\DataProvider('legalUrlProvider')]
199
+    public function testGetPrivacyURL(string $privacyUrl): void {
200
+        $this->appConfig
201
+            ->expects($this->once())
202
+            ->method('getAppValueString')
203
+            ->with('privacyUrl', '')
204
+            ->willReturn($privacyUrl);
205
+
206
+        $this->assertEquals($privacyUrl, $this->template->getPrivacyUrl());
207
+    }
208
+
209
+    public function testGetSloganWithDefault(): void {
210
+        $this->appConfig
211
+            ->expects($this->once())
212
+            ->method('getAppValueString')
213
+            ->with('slogan', $this->defaults->getSlogan())
214
+            ->willReturn($this->defaults->getSlogan());
215
+
216
+        $this->assertEquals($this->defaults->getSlogan(), $this->template->getSlogan());
217
+    }
218
+
219
+    public function testGetSloganWithCustom(): void {
220
+        $this->appConfig
221
+            ->expects($this->once())
222
+            ->method('getAppValueString')
223
+            ->with('slogan', $this->defaults->getSlogan())
224
+            ->willReturn('My custom Slogan');
225
+
226
+        $this->assertEquals('My custom Slogan', $this->template->getSlogan());
227
+    }
228
+
229
+    public function testGetShortFooter(): void {
230
+        $this->appConfig
231
+            ->expects($this->exactly(5))
232
+            ->method('getAppValueString')
233
+            ->willReturnMap([
234
+                ['url', $this->defaults->getBaseUrl(), 'url'],
235
+                ['name', 'Nextcloud', 'Name'],
236
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
237
+                ['imprintUrl', '', ''],
238
+                ['privacyUrl', '', ''],
239
+            ]);
240
+
241
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
242
+    }
243
+
244
+    public function testGetShortFooterEmptyUrl(): void {
245
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
246
+        $this->appConfig
247
+            ->expects($this->exactly(5))
248
+            ->method('getAppValueString')
249
+            ->willReturnMap([
250
+                ['url', $this->defaults->getBaseUrl(), ''],
251
+                ['name', 'Nextcloud', 'Name'],
252
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
253
+                ['imprintUrl', '', ''],
254
+                ['privacyUrl', '', ''],
255
+            ]);
256
+
257
+        $this->assertEquals('<span class="entity-name">Name</span> – Slogan', $this->template->getShortFooter());
258
+    }
259
+
260
+    public function testGetShortFooterEmptySlogan(): void {
261
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
262
+        $this->appConfig
263
+            ->expects($this->exactly(5))
264
+            ->method('getAppValueString')
265
+            ->willReturnMap([
266
+                ['url', $this->defaults->getBaseUrl(), 'url'],
267
+                ['name', 'Nextcloud', 'Name'],
268
+                ['slogan', $this->defaults->getSlogan(), ''],
269
+                ['imprintUrl', '', ''],
270
+                ['privacyUrl', '', ''],
271
+            ]);
272
+
273
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a>', $this->template->getShortFooter());
274
+    }
275
+
276
+    public function testGetShortFooterImprint(): void {
277
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
278
+        $this->appConfig
279
+            ->expects($this->exactly(5))
280
+            ->method('getAppValueString')
281
+            ->willReturnMap([
282
+                ['url', $this->defaults->getBaseUrl(), 'url'],
283
+                ['name', 'Nextcloud', 'Name'],
284
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
285
+                ['imprintUrl', '', 'https://example.com/imprint'],
286
+                ['privacyUrl', '', ''],
287
+            ]);
288
+
289
+        $this->l10n
290
+            ->expects($this->any())
291
+            ->method('t')
292
+            ->willReturnArgument(0);
293
+
294
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a></span>', $this->template->getShortFooter());
295
+    }
296
+
297
+    public function testGetShortFooterPrivacy(): void {
298
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
299
+        $this->appConfig
300
+            ->expects($this->exactly(5))
301
+            ->method('getAppValueString')
302
+            ->willReturnMap([
303
+                ['url', $this->defaults->getBaseUrl(), 'url'],
304
+                ['name', 'Nextcloud', 'Name'],
305
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
306
+                ['imprintUrl', '', ''],
307
+                ['privacyUrl', '', 'https://example.com/privacy'],
308
+            ]);
309
+
310
+        $this->l10n
311
+            ->expects($this->any())
312
+            ->method('t')
313
+            ->willReturnArgument(0);
314
+
315
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a></span>', $this->template->getShortFooter());
316
+    }
317
+
318
+    public function testGetShortFooterAllLegalLinks(): void {
319
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
320
+        $this->appConfig
321
+            ->expects($this->exactly(5))
322
+            ->method('getAppValueString')
323
+            ->willReturnMap([
324
+                ['url', $this->defaults->getBaseUrl(), 'url'],
325
+                ['name', 'Nextcloud', 'Name'],
326
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
327
+                ['imprintUrl', '', 'https://example.com/imprint'],
328
+                ['privacyUrl', '', 'https://example.com/privacy'],
329
+            ]);
330
+
331
+        $this->l10n
332
+            ->expects($this->any())
333
+            ->method('t')
334
+            ->willReturnArgument(0);
335
+
336
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan<br/><span class="footer__legal-links"><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a> · <a href="https://example.com/privacy" class="legal" target="_blank" rel="noreferrer noopener">Privacy policy</a></span>', $this->template->getShortFooter());
337
+    }
338
+
339
+    public static function invalidLegalUrlProvider(): array {
340
+        return [
341
+            ['example.com/legal'],  # missing scheme
342
+            ['https:///legal'],     # missing host
343
+        ];
344
+    }
345
+
346
+    #[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')]
347
+    public function testGetShortFooterInvalidImprint(string $invalidImprintUrl): void {
348
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
349
+        $this->appConfig
350
+            ->expects($this->exactly(5))
351
+            ->method('getAppValueString')
352
+            ->willReturnMap([
353
+                ['url', $this->defaults->getBaseUrl(), 'url'],
354
+                ['name', 'Nextcloud', 'Name'],
355
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
356
+                ['imprintUrl', '', $invalidImprintUrl],
357
+                ['privacyUrl', '', ''],
358
+            ]);
359
+
360
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
361
+    }
362
+
363
+    #[\PHPUnit\Framework\Attributes\DataProvider('invalidLegalUrlProvider')]
364
+    public function testGetShortFooterInvalidPrivacy(string $invalidPrivacyUrl): void {
365
+        $this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
366
+        $this->appConfig
367
+            ->expects($this->exactly(5))
368
+            ->method('getAppValueString')
369
+            ->willReturnMap([
370
+                ['url', $this->defaults->getBaseUrl(), 'url'],
371
+                ['name', 'Nextcloud', 'Name'],
372
+                ['slogan', $this->defaults->getSlogan(), 'Slogan'],
373
+                ['imprintUrl', '', ''],
374
+                ['privacyUrl', '', $invalidPrivacyUrl],
375
+            ]);
376
+
377
+        $this->assertEquals('<a href="url" target="_blank" rel="noreferrer noopener" class="entity-name">Name</a> – Slogan', $this->template->getShortFooter());
378
+    }
379
+
380
+    public function testGetColorPrimaryWithDefault(): void {
381
+        $this->appConfig
382
+            ->expects(self::once())
383
+            ->method('getAppValueBool')
384
+            ->with('disable-user-theming')
385
+            ->willReturn(false);
386
+        $this->appConfig
387
+            ->expects(self::once())
388
+            ->method('getAppValueString')
389
+            ->with('primary_color', '')
390
+            ->willReturn($this->defaults->getColorPrimary());
391
+
392
+        $this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
393
+    }
394
+
395
+    public function testGetColorPrimaryWithCustom(): void {
396
+        $this->appConfig
397
+            ->expects(self::once())
398
+            ->method('getAppValueBool')
399
+            ->with('disable-user-theming')
400
+            ->willReturn(false);
401
+        $this->appConfig
402
+            ->expects(self::once())
403
+            ->method('getAppValueString')
404
+            ->with('primary_color', '')
405
+            ->willReturn('#fff');
406
+
407
+        $this->assertEquals('#fff', $this->template->getColorPrimary());
408
+    }
409
+
410
+    public static function dataGetColorPrimary(): array {
411
+        return [
412
+            'with fallback default' => [
413
+                'disableTheming' => false,
414
+                'primaryColor' => '',
415
+                'userPrimaryColor' => '',
416
+                'expected' => BackgroundService::DEFAULT_COLOR,
417
+            ],
418
+            'with custom admin primary' => [
419
+                'disableTheming' => false,
420
+                'primaryColor' => '#aaa',
421
+                'userPrimaryColor' => '',
422
+                'expected' => '#aaa',
423
+            ],
424
+            'with custom invalid admin primary' => [
425
+                'disableTheming' => false,
426
+                'primaryColor' => 'invalid',
427
+                'userPrimaryColor' => '',
428
+                'expected' => BackgroundService::DEFAULT_COLOR,
429
+            ],
430
+            'with custom invalid user primary' => [
431
+                'disableTheming' => false,
432
+                'primaryColor' => '',
433
+                'userPrimaryColor' => 'invalid-name',
434
+                'expected' => BackgroundService::DEFAULT_COLOR,
435
+            ],
436
+            'with custom user primary' => [
437
+                'disableTheming' => false,
438
+                'primaryColor' => '',
439
+                'userPrimaryColor' => '#bbb',
440
+                'expected' => '#bbb',
441
+            ],
442
+            'with disabled user theming primary' => [
443
+                'disableTheming' => true,
444
+                'primaryColor' => '#aaa',
445
+                'userPrimaryColor' => '#bbb',
446
+                'expected' => '#aaa',
447
+            ],
448
+        ];
449
+    }
450
+
451
+    #[\PHPUnit\Framework\Attributes\DataProvider('dataGetColorPrimary')]
452
+    public function testGetColorPrimary(bool $disableTheming, string $primaryColor, string $userPrimaryColor, string $expected): void {
453
+        $user = $this->createMock(IUser::class);
454
+        $this->userSession->expects($this->any())
455
+            ->method('getUser')
456
+            ->willReturn($user);
457
+        $user->expects($this->any())
458
+            ->method('getUID')
459
+            ->willReturn('user');
460
+        $this->appConfig
461
+            ->expects(self::any())
462
+            ->method('getAppValueBool')
463
+            ->with('disable-user-theming')
464
+            ->willReturn($disableTheming);
465
+        $this->appConfig
466
+            ->expects(self::any())
467
+            ->method('getAppValueString')
468
+            ->with('primary_color', '')
469
+            ->willReturn($primaryColor);
470
+        $this->config
471
+            ->expects($this->any())
472
+            ->method('getUserValue')
473
+            ->with('user', 'theming', 'primary_color', '')
474
+            ->willReturn($userPrimaryColor);
475
+
476
+        $this->assertEquals($expected, $this->template->getColorPrimary());
477
+    }
478
+
479
+    public function testSet(): void {
480
+        $this->appConfig
481
+            ->expects($this->once())
482
+            ->method('setAppValueInt')
483
+            ->with('cachebuster', 16);
484
+        $this->appConfig
485
+            ->expects($this->once())
486
+            ->method('setAppValueString')
487
+            ->with('MySetting', 'MyValue');
488
+        $this->appConfig
489
+            ->expects($this->once())
490
+            ->method('getAppValueInt')
491
+            ->with('cachebuster')
492
+            ->willReturn(15);
493
+        $this->cacheFactory
494
+            ->expects($this->exactly(2))
495
+            ->method('createDistributed')
496
+            ->willReturnMap([
497
+                ['theming-', $this->cache],
498
+                ['imagePath', $this->cache],
499
+            ]);
500
+        $this->cache
501
+            ->expects($this->any())
502
+            ->method('clear')
503
+            ->with('');
504
+        $this->template->set('MySetting', 'MyValue');
505
+    }
506
+
507
+    public function testUndoName(): void {
508
+        $this->appConfig
509
+            ->expects($this->once())
510
+            ->method('deleteAppValue')
511
+            ->with('name');
512
+        $this->appConfig
513
+            ->expects($this->once())
514
+            ->method('getAppValueInt')
515
+            ->with('cachebuster')
516
+            ->willReturn(15);
517
+        $this->appConfig
518
+            ->expects($this->once())
519
+            ->method('getAppValueString')
520
+            ->with('name', 'Nextcloud')
521
+            ->willReturn('Nextcloud');
522
+        $this->appConfig
523
+            ->expects($this->once())
524
+            ->method('setAppValueInt')
525
+            ->with('cachebuster', 16);
526
+
527
+        $this->assertSame('Nextcloud', $this->template->undo('name'));
528
+    }
529
+
530
+    public function testUndoBaseUrl(): void {
531
+        $this->appConfig
532
+            ->expects($this->once())
533
+            ->method('deleteAppValue')
534
+            ->with('url');
535
+        $this->appConfig
536
+            ->expects($this->once())
537
+            ->method('getAppValueInt')
538
+            ->with('cachebuster')
539
+            ->willReturn(15);
540
+        $this->appConfig
541
+            ->expects($this->once())
542
+            ->method('getAppValueString')
543
+            ->with('url', $this->defaults->getBaseUrl())
544
+            ->willReturn($this->defaults->getBaseUrl());
545
+        $this->appConfig
546
+            ->expects($this->once())
547
+            ->method('setAppValueInt')
548
+            ->with('cachebuster', 16);
549
+
550
+        $this->assertSame($this->defaults->getBaseUrl(), $this->template->undo('url'));
551
+    }
552
+
553
+    public function testUndoSlogan(): void {
554
+        $this->appConfig
555
+            ->expects($this->once())
556
+            ->method('deleteAppValue')
557
+            ->with('slogan');
558
+        $this->appConfig
559
+            ->expects($this->once())
560
+            ->method('getAppValueInt')
561
+            ->with('cachebuster')
562
+            ->willReturn(15);
563
+        $this->appConfig
564
+            ->expects($this->once())
565
+            ->method('getAppValueString')
566
+            ->with('slogan', $this->defaults->getSlogan())
567
+            ->willReturn($this->defaults->getSlogan());
568
+        $this->appConfig
569
+            ->expects($this->once())
570
+            ->method('setAppValueInt')
571
+            ->with('cachebuster', 16);
572
+
573
+        $this->assertSame($this->defaults->getSlogan(), $this->template->undo('slogan'));
574
+    }
575
+
576
+    public function testUndoPrimaryColor(): void {
577
+        $this->appConfig
578
+            ->expects($this->once())
579
+            ->method('deleteAppValue')
580
+            ->with('primary_color');
581
+        $this->appConfig
582
+            ->expects($this->once())
583
+            ->method('getAppValueInt')
584
+            ->with('cachebuster')
585
+            ->willReturn(15);
586
+        $this->appConfig
587
+            ->expects($this->once())
588
+            ->method('setAppValueInt')
589
+            ->with('cachebuster', 16);
590
+
591
+        $this->assertSame($this->defaults->getColorPrimary(), $this->template->undo('primary_color'));
592
+    }
593
+
594
+    public function testUndoDefaultAction(): void {
595
+        $this->appConfig
596
+            ->expects($this->once())
597
+            ->method('deleteAppValue')
598
+            ->with('defaultitem');
599
+        $this->appConfig
600
+            ->expects($this->once())
601
+            ->method('getAppValueInt')
602
+            ->with('cachebuster', '0')
603
+            ->willReturn(15);
604
+        $this->appConfig
605
+            ->expects($this->once())
606
+            ->method('setAppValueInt')
607
+            ->with('cachebuster', 16);
608
+
609
+        $this->assertSame('', $this->template->undo('defaultitem'));
610
+    }
611
+
612
+    public function testGetBackground(): void {
613
+        $this->imageManager
614
+            ->expects($this->once())
615
+            ->method('getImageUrl')
616
+            ->with('background')
617
+            ->willReturn('custom-background?v=0');
618
+        $this->assertEquals('custom-background?v=0', $this->template->getBackground());
619
+    }
620
+
621
+    private function getLogoHelper($withName, $useSvg) {
622
+        $this->imageManager->expects($this->any())
623
+            ->method('getImage')
624
+            ->with('logo')
625
+            ->willThrowException(new NotFoundException());
626
+        $this->appConfig
627
+            ->expects($this->once())
628
+            ->method('getAppValueString')
629
+            ->with('logoMime', '')
630
+            ->willReturn('');
631
+        $this->appConfig
632
+            ->expects($this->once())
633
+            ->method('getAppValueInt')
634
+            ->with('cachebuster')
635
+            ->willReturn(0);
636
+        $this->urlGenerator->expects($this->once())
637
+            ->method('imagePath')
638
+            ->with('core', $withName)
639
+            ->willReturn('core-logo');
640
+        $this->assertEquals('core-logo?v=0', $this->template->getLogo($useSvg));
641
+    }
642
+
643
+    public function testGetLogoDefaultWithSvg(): void {
644
+        $this->getLogoHelper('logo/logo.svg', true);
645
+    }
646
+
647
+    public function testGetLogoDefaultWithoutSvg(): void {
648
+        $this->getLogoHelper('logo/logo.png', false);
649
+    }
650
+
651
+    public function testGetLogoCustom(): void {
652
+        $this->appConfig
653
+            ->expects($this->once())
654
+            ->method('getAppValueString')
655
+            ->with('logoMime', '')
656
+            ->willReturn('image/svg+xml');
657
+        $this->appConfig
658
+            ->expects($this->once())
659
+            ->method('getAppValueInt')
660
+            ->with('cachebuster')
661
+            ->willReturn(0);
662
+        $this->urlGenerator->expects($this->once())
663
+            ->method('linkToRoute')
664
+            ->with('theming.Theming.getImage')
665
+            ->willReturn('custom-logo?v=0');
666
+        $this->assertEquals('custom-logo' . '?v=0', $this->template->getLogo());
667
+    }
668
+
669
+    public function testGetScssVariablesCached(): void {
670
+        $this->appConfig->expects($this->any())
671
+            ->method('getAppValueInt')
672
+            ->with('cachebuster')
673
+            ->willReturn(1);
674
+        $this->cacheFactory->expects($this->once())
675
+            ->method('createDistributed')
676
+            ->with('theming-1-')
677
+            ->willReturn($this->cache);
678
+        $this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(['foo' => 'bar']);
679
+        $this->assertEquals(['foo' => 'bar'], $this->template->getScssVariables());
680
+    }
681
+
682
+    public function testGetScssVariables(): void {
683
+        $this->appConfig->expects($this->any())
684
+            ->method('getAppValueInt')
685
+            ->with('cachebuster')
686
+            ->willReturn(0);
687
+        $this->appConfig
688
+            ->expects($this->any())
689
+            ->method('getAppValueString')
690
+            ->willReturnMap([
691
+                ['imprintUrl', '', ''],
692
+                ['privacyUrl', '', ''],
693
+                ['logoMime', '', 'jpeg'],
694
+                ['backgroundMime', '', 'jpeg'],
695
+                ['logoheaderMime', '', 'jpeg'],
696
+                ['faviconMime', '', 'jpeg'],
697
+                ['primary_color', '', false, $this->defaults->getColorPrimary()],
698
+                ['primary_color', $this->defaults->getColorPrimary(), false, $this->defaults->getColorPrimary()],
699
+            ]);
700
+
701
+        $this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false);
702
+        $this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa');
703
+        $this->cacheFactory->expects($this->once())
704
+            ->method('createDistributed')
705
+            ->with('theming-0-')
706
+            ->willReturn($this->cache);
707
+        $this->cache->expects($this->once())->method('get')->with('getScssVariables')->willReturn(null);
708
+        $this->imageManager->expects($this->exactly(4))
709
+            ->method('getImageUrl')
710
+            ->willReturnMap([
711
+                ['logo', 'custom-logo?v=0'],
712
+                ['logoheader', 'custom-logoheader?v=0'],
713
+                ['favicon', 'custom-favicon?v=0'],
714
+                ['background', 'custom-background?v=0'],
715
+            ]);
716
+
717
+        $expected = [
718
+            'theming-cachebuster' => '\'0\'',
719
+            'theming-logo-mime' => '\'jpeg\'',
720
+            'theming-background-mime' => '\'jpeg\'',
721
+            'image-logo' => "url('custom-logo?v=0')",
722
+            'image-login-background' => "url('custom-background?v=0')",
723
+            'color-primary' => $this->defaults->getColorPrimary(),
724
+            'color-primary-text' => '#ffffff',
725
+            'image-login-plain' => 'false',
726
+            'color-primary-element' => '#aaaaaa',
727
+            'theming-logoheader-mime' => '\'jpeg\'',
728
+            'theming-favicon-mime' => '\'jpeg\'',
729
+            'image-logoheader' => "url('custom-logoheader?v=0')",
730
+            'image-favicon' => "url('custom-favicon?v=0')",
731
+            'has-legal-links' => 'false'
732
+        ];
733
+        $this->assertEquals($expected, $this->template->getScssVariables());
734
+    }
735
+
736
+    public function testGetDefaultAndroidURL(): void {
737
+        $this->appConfig
738
+            ->expects($this->once())
739
+            ->method('getAppValueString')
740
+            ->with('AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
741
+            ->willReturn('https://play.google.com/store/apps/details?id=com.nextcloud.client');
742
+
743
+        $this->assertEquals('https://play.google.com/store/apps/details?id=com.nextcloud.client', $this->template->getAndroidClientUrl());
744
+    }
745
+
746
+    public function testGetCustomAndroidURL(): void {
747
+        $this->appConfig
748
+            ->expects($this->once())
749
+            ->method('getAppValueString')
750
+            ->with('AndroidClientUrl', 'https://play.google.com/store/apps/details?id=com.nextcloud.client')
751
+            ->willReturn('https://play.google.com/store/apps/details?id=com.mycloud.client');
752
+
753
+        $this->assertEquals('https://play.google.com/store/apps/details?id=com.mycloud.client', $this->template->getAndroidClientUrl());
754
+    }
755
+
756
+    public function testGetDefaultiOSURL(): void {
757
+        $this->appConfig
758
+            ->expects($this->once())
759
+            ->method('getAppValueString')
760
+            ->with('iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
761
+            ->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
762
+
763
+        $this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', $this->template->getiOSClientUrl());
764
+    }
765
+
766
+    public function testGetCustomiOSURL(): void {
767
+        $this->appConfig
768
+            ->expects($this->once())
769
+            ->method('getAppValueString')
770
+            ->with('iOSClientUrl', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8')
771
+            ->willReturn('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8');
772
+
773
+        $this->assertEquals('https://geo.itunes.apple.com/us/app/nextcloud/id1234567890?mt=8', $this->template->getiOSClientUrl());
774
+    }
775
+
776
+    public function testGetDefaultiTunesAppId(): void {
777
+        $this->appConfig
778
+            ->expects($this->once())
779
+            ->method('getAppValueString')
780
+            ->with('iTunesAppId', '1125420102')
781
+            ->willReturn('1125420102');
782
+
783
+        $this->assertEquals('1125420102', $this->template->getiTunesAppId());
784
+    }
785
+
786
+    public function testGetCustomiTunesAppId(): void {
787
+        $this->appConfig
788
+            ->expects($this->once())
789
+            ->method('getAppValueString')
790
+            ->with('iTunesAppId', '1125420102')
791
+            ->willReturn('1234567890');
792
+
793
+        $this->assertEquals('1234567890', $this->template->getiTunesAppId());
794
+    }
795
+
796
+    public static function dataReplaceImagePath(): array {
797
+        return [
798
+            ['core', 'test.png', false],
799
+            ['core', 'manifest.json'],
800
+            ['core', 'favicon.ico'],
801
+            ['core', 'favicon-touch.png']
802
+        ];
803
+    }
804
+
805
+    #[\PHPUnit\Framework\Attributes\DataProvider('dataReplaceImagePath')]
806
+    public function testReplaceImagePath(string $app, string $image, string|bool $result = 'themingRoute?v=1234abcd'): void {
807
+        $this->cache->expects($this->any())
808
+            ->method('get')
809
+            ->with('shouldReplaceIcons')
810
+            ->willReturn(true);
811
+        $this->appConfig
812
+            ->expects($this->any())
813
+            ->method('getAppValueInt')
814
+            ->with('cachebuster')
815
+            ->willReturn(0);
816
+        $this->urlGenerator
817
+            ->expects($this->any())
818
+            ->method('linkToRoute')
819
+            ->willReturn('themingRoute');
820
+        if ($result) {
821
+            $this->util
822
+                ->expects($this->once())
823
+                ->method('getCacheBuster')
824
+                ->willReturn('1234abcd');
825
+        }
826
+        $this->assertEquals($result, $this->template->replaceImagePath($app, $image));
827
+    }
828 828
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 
339 339
 	public static function invalidLegalUrlProvider(): array {
340 340
 		return [
341
-			['example.com/legal'],  # missing scheme
342
-			['https:///legal'],     # missing host
341
+			['example.com/legal'], # missing scheme
342
+			['https:///legal'], # missing host
343 343
 		];
344 344
 	}
345 345
 
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 			->method('linkToRoute')
664 664
 			->with('theming.Theming.getImage')
665 665
 			->willReturn('custom-logo?v=0');
666
-		$this->assertEquals('custom-logo' . '?v=0', $this->template->getLogo());
666
+		$this->assertEquals('custom-logo'.'?v=0', $this->template->getLogo());
667 667
 	}
668 668
 
669 669
 	public function testGetScssVariablesCached(): void {
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	}
804 804
 
805 805
 	#[\PHPUnit\Framework\Attributes\DataProvider('dataReplaceImagePath')]
806
-	public function testReplaceImagePath(string $app, string $image, string|bool $result = 'themingRoute?v=1234abcd'): void {
806
+	public function testReplaceImagePath(string $app, string $image, string | bool $result = 'themingRoute?v=1234abcd'): void {
807 807
 		$this->cache->expects($this->any())
808 808
 			->method('get')
809 809
 			->with('shouldReplaceIcons')
Please login to merge, or discard this patch.