Merge pull request #24063 from nextcloud/techdebt/noid/switch-to-class-names-for-encryption-DI

Change to full class names for the encryption app DI in preparation of auto-wiring
This commit is contained in:
Morris Jobke 2020-11-11 22:34:17 +01:00 committed by GitHub
commit 2b43644833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 46 deletions

View File

@ -70,7 +70,7 @@ class Application extends \OCP\AppFramework\App {
public function setUp() { public function setUp() {
if ($this->encryptionManager->isEnabled()) { if ($this->encryptionManager->isEnabled()) {
/** @var Setup $setup */ /** @var Setup $setup */
$setup = $this->getContainer()->query('UserSetup'); $setup = $this->getContainer()->query(Setup::class);
$setup->setupSystem(); $setup->setupSystem();
} }
} }
@ -86,15 +86,15 @@ class Application extends \OCP\AppFramework\App {
$hookManager = new HookManager(); $hookManager = new HookManager();
$hookManager->registerHook([ $hookManager->registerHook([
new UserHooks($container->query('KeyManager'), new UserHooks($container->query(KeyManager::class),
$server->getUserManager(), $server->getUserManager(),
$server->getLogger(), $server->getLogger(),
$container->query('UserSetup'), $container->query(Setup::class),
$server->getUserSession(), $server->getUserSession(),
$container->query('Util'), $container->query(Util::class),
$container->query('Session'), $container->query(Session::class),
$container->query('Crypt'), $container->query(Crypt::class),
$container->query('Recovery')) $container->query(Recovery::class))
]); ]);
$hookManager->fireHooks(); $hookManager->fireHooks();
@ -113,12 +113,12 @@ class Application extends \OCP\AppFramework\App {
Encryption::DISPLAY_NAME, Encryption::DISPLAY_NAME,
function () use ($container) { function () use ($container) {
return new Encryption( return new Encryption(
$container->query('Crypt'), $container->query(Crypt::class),
$container->query('KeyManager'), $container->query(KeyManager::class),
$container->query('Util'), $container->query(Util::class),
$container->query('Session'), $container->query(Session::class),
$container->query('EncryptAll'), $container->query(EncryptAll::class),
$container->query('DecryptAll'), $container->query(DecryptAll::class),
$container->getServer()->getLogger(), $container->getServer()->getLogger(),
$container->getServer()->getL10N($container->getAppName()) $container->getServer()->getL10N($container->getAppName())
); );
@ -128,7 +128,7 @@ class Application extends \OCP\AppFramework\App {
public function registerServices() { public function registerServices() {
$container = $this->getContainer(); $container = $this->getContainer();
$container->registerService('Crypt', function (ContainerInterface $c) { $container->registerService(Crypt::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new Crypt($server->getLogger(), return new Crypt($server->getLogger(),
@ -137,42 +137,42 @@ class Application extends \OCP\AppFramework\App {
$server->getL10N($c->get('AppName'))); $server->getL10N($c->get('AppName')));
}); });
$container->registerService('Session', function (ContainerInterface $c) { $container->registerService(Session::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new Session($server->getSession()); return new Session($server->getSession());
} }
); );
$container->registerService('KeyManager', function (ContainerInterface $c) { $container->registerService(KeyManager::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new KeyManager($server->getEncryptionKeyStorage(), return new KeyManager($server->getEncryptionKeyStorage(),
$c->get('Crypt'), $c->get(Crypt::class),
$server->getConfig(), $server->getConfig(),
$server->getUserSession(), $server->getUserSession(),
new Session($server->getSession()), new Session($server->getSession()),
$server->getLogger(), $server->getLogger(),
$c->get('Util'), $c->get(Util::class),
$server->getLockingProvider() $server->getLockingProvider()
); );
}); });
$container->registerService('Recovery', function (ContainerInterface $c) { $container->registerService(Recovery::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new Recovery( return new Recovery(
$server->getUserSession(), $server->getUserSession(),
$c->get('Crypt'), $c->get(Crypt::class),
$c->get('KeyManager'), $c->get(KeyManager::class),
$server->getConfig(), $server->getConfig(),
$server->getEncryptionFilesHelper(), $server->getEncryptionFilesHelper(),
new View()); new View());
}); });
$container->registerService('RecoveryController', function (ContainerInterface $c) { $container->registerService(RecoveryController::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new RecoveryController( return new RecoveryController(
@ -180,22 +180,22 @@ class Application extends \OCP\AppFramework\App {
$server->getRequest(), $server->getRequest(),
$server->getConfig(), $server->getConfig(),
$server->getL10N($c->get('AppName')), $server->getL10N($c->get('AppName')),
$c->get('Recovery')); $c->get(Recovery::class));
}); });
$container->registerService('StatusController', function (ContainerInterface $c) { $container->registerService(StatusController::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new StatusController( return new StatusController(
$c->get('AppName'), $c->get('AppName'),
$server->getRequest(), $server->getRequest(),
$server->getL10N($c->get('AppName')), $server->getL10N($c->get('AppName')),
$c->get('Session'), $c->get(Session::class),
$server->getEncryptionManager() $server->getEncryptionManager()
); );
}); });
$container->registerService('SettingsController', function (ContainerInterface $c) { $container->registerService(SettingsController::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new SettingsController( return new SettingsController(
@ -204,45 +204,45 @@ class Application extends \OCP\AppFramework\App {
$server->getL10N($c->get('AppName')), $server->getL10N($c->get('AppName')),
$server->getUserManager(), $server->getUserManager(),
$server->getUserSession(), $server->getUserSession(),
$c->get('KeyManager'), $c->get(KeyManager::class),
$c->get('Crypt'), $c->get(Crypt::class),
$c->get('Session'), $c->get(Session::class),
$server->getSession(), $server->getSession(),
$c->get('Util') $c->get(Util::class)
); );
}); });
$container->registerService('UserSetup', function (ContainerInterface $c) { $container->registerService(Setup::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new Setup($server->getLogger(), return new Setup($server->getLogger(),
$server->getUserSession(), $server->getUserSession(),
$c->get('Crypt'), $c->get(Crypt::class),
$c->get('KeyManager')); $c->get(KeyManager::class));
}); });
$container->registerService('Util', function (ContainerInterface $c) { $container->registerService(Util::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new Util( return new Util(
new View(), new View(),
$c->get('Crypt'), $c->get(Crypt::class),
$server->getLogger(), $server->getLogger(),
$server->getUserSession(), $server->getUserSession(),
$server->getConfig(), $server->getConfig(),
$server->getUserManager()); $server->getUserManager());
}); });
$container->registerService('EncryptAll', function (ContainerInterface $c) { $container->registerService(EncryptAll::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */ /** @var IServerContainer $server */
$server = $c->get(IServerContainer::class); $server = $c->get(IServerContainer::class);
return new EncryptAll( return new EncryptAll(
$c->get('UserSetup'), $c->get(Setup::class),
$server->getUserManager(), $server->getUserManager(),
new View(), new View(),
$c->get('KeyManager'), $c->get(KeyManager::class),
$c->get('Util'), $c->get(Util::class),
$server->getConfig(), $server->getConfig(),
$server->getMailer(), $server->getMailer(),
$server->getL10N('encryption'), $server->getL10N('encryption'),
@ -252,12 +252,12 @@ class Application extends \OCP\AppFramework\App {
} }
); );
$container->registerService('DecryptAll',function (ContainerInterface $c) { $container->registerService(DecryptAll::class,function (ContainerInterface $c) {
return new DecryptAll( return new DecryptAll(
$c->get('Util'), $c->get(Util::class),
$c->get('KeyManager'), $c->get(KeyManager::class),
$c->get('Crypt'), $c->get(Crypt::class),
$c->get('Session'), $c->get(Session::class),
new QuestionHelper() new QuestionHelper()
); );
} }

View File

@ -60,9 +60,9 @@ trait EncryptionTrait {
\OC_Util::setupFS($name); \OC_Util::setupFS($name);
$container = $this->encryptionApp->getContainer(); $container = $this->encryptionApp->getContainer();
/** @var KeyManager $keyManager */ /** @var KeyManager $keyManager */
$keyManager = $container->query('KeyManager'); $keyManager = $container->query(KeyManager::class);
/** @var Setup $userSetup */ /** @var Setup $userSetup */
$userSetup = $container->query('UserSetup'); $userSetup = $container->query(Setup::class);
$userSetup->setupUser($name, $password); $userSetup->setupUser($name, $password);
$this->encryptionApp->setUp(); $this->encryptionApp->setUp();
$keyManager->init($name, $password); $keyManager->init($name, $password);