Merge pull request #24267 from nextcloud/techdebt/noid/auto-wire-encryption-app-view-dependent

Auto-wire remaining encryption app services that depend on View
This commit is contained in:
Morris Jobke 2020-11-22 22:33:53 +01:00 committed by GitHub
commit 9a0428835f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 54 deletions

View File

@ -29,7 +29,6 @@
namespace OCA\Encryption\AppInfo;
use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Crypto\DecryptAll;
use OCA\Encryption\Crypto\EncryptAll;
@ -43,9 +42,6 @@ use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\Encryption\IManager;
use OCP\IConfig;
use OCP\IServerContainer;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Helper\QuestionHelper;
class Application extends \OCP\AppFramework\App {
@ -61,7 +57,6 @@ class Application extends \OCP\AppFramework\App {
parent::__construct('encryption', $urlParams);
$this->encryptionManager = \OC::$server->getEncryptionManager();
$this->config = \OC::$server->getConfig();
$this->registerServices();
}
public function setUp() {
@ -121,53 +116,4 @@ class Application extends \OCP\AppFramework\App {
);
});
}
public function registerServices() {
$container = $this->getContainer();
$container->registerService(Recovery::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
return new Recovery(
$server->getUserSession(),
$c->get(Crypt::class),
$c->get(KeyManager::class),
$server->getConfig(),
$server->getEncryptionFilesHelper(),
new View());
});
$container->registerService(Util::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
return new Util(
new View(),
$c->get(Crypt::class),
$server->getLogger(),
$server->getUserSession(),
$server->getConfig(),
$server->getUserManager());
});
$container->registerService(EncryptAll::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
return new EncryptAll(
$c->get(Setup::class),
$server->getUserManager(),
new View(),
$c->get(KeyManager::class),
$c->get(Util::class),
$server->getConfig(),
$server->getMailer(),
$server->getL10N('encryption'),
new QuestionHelper(),
$server->getSecureRandom()
);
}
);
}
}

View File

@ -290,6 +290,9 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerAlias(IActionFactory::class, ActionFactory::class);
$this->registerService(View::class, function (Server $c) {
return new View();
}, false);
$this->registerService(IPreview::class, function (ContainerInterface $c) {
return new PreviewManager(