]> source.dussan.org Git - nextcloud-server.git/commitdiff
Migrate settigns to the PSR container 21865/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 16 Jul 2020 08:34:53 +0000 (10:34 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 16 Jul 2020 13:55:04 +0000 (15:55 +0200)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/settings/lib/AppInfo/Application.php

index 27f51a32f106114325362c04dfa4eafbc084bc56..73db869bc6a125abe36cf4b05618ef938f7094a1 100644 (file)
@@ -51,12 +51,13 @@ use OCP\AppFramework\Bootstrap\IBootContext;
 use OCP\AppFramework\Bootstrap\IBootstrap;
 use OCP\AppFramework\Bootstrap\IRegistrationContext;
 use OCP\Defaults;
-use OCP\IContainer;
 use OCP\IGroup;
 use OCP\ILogger;
+use OCP\IServerContainer;
 use OCP\IUser;
 use OCP\Settings\IManager;
 use OCP\Util;
+use Psr\Container\ContainerInterface;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\EventDispatcher\GenericEvent;
 
@@ -83,7 +84,7 @@ class Application extends App implements IBootstrap {
                        return \OC_User::isAdminUser(\OC_User::getUser());
                });
                /** FIXME: Remove once OC_SubAdmin is non-static and mockable */
-               $context->registerService('isSubAdmin', function (IContainer $c) {
+               $context->registerService('isSubAdmin', function () {
                        $userObject = \OC::$server->getUserSession()->getUser();
                        $isSubAdmin = false;
                        if ($userObject !== null) {
@@ -91,22 +92,30 @@ class Application extends App implements IBootstrap {
                        }
                        return $isSubAdmin;
                });
-               $context->registerService('userCertificateManager', function (IContainer $c) {
-                       return $c->query('ServerContainer')->getCertificateManager();
+               $context->registerService('userCertificateManager', function (ContainerInterface $c) {
+                       /** @var IServerContainer $serverContainer */
+                       $serverContainer = $c->get(IServerContainer::class);
+                       return $serverContainer->getCertificateManager();
                }, false);
-               $context->registerService('systemCertificateManager', function (IContainer $c) {
-                       return $c->query('ServerContainer')->getCertificateManager(null);
+               $context->registerService('systemCertificateManager', function (ContainerInterface $c) {
+                       /** @var IServerContainer $serverContainer */
+                       $serverContainer = $c->query('ServerContainer');
+                       return $serverContainer->getCertificateManager(null);
                }, false);
-               $context->registerService(IProvider::class, function (IContainer $c) {
-                       return $c->query('ServerContainer')->query(IProvider::class);
+               $context->registerService(IProvider::class, function (ContainerInterface $c) {
+                       /** @var IServerContainer $serverContainer */
+                       $serverContainer = $c->query(IServerContainer::class);
+                       return $serverContainer->query(IProvider::class);
                });
-               $context->registerService(IManager::class, function (IContainer $c) {
-                       return $c->query('ServerContainer')->getSettingsManager();
+               $context->registerService(IManager::class, function (ContainerInterface $c) {
+                       /** @var IServerContainer $serverContainer */
+                       $serverContainer = $c->query(IServerContainer::class);
+                       return $serverContainer->getSettingsManager();
                });
 
-               $context->registerService(NewUserMailHelper::class, function (IContainer $c) {
+               $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) {
                        /** @var Server $server */
-                       $server = $c->query('ServerContainer');
+                       $server = $c->query(IServerContainer::class);
                        /** @var Defaults $defaults */
                        $defaults = $server->query(Defaults::class);