Auto-wire as much as possible in the encryption app
Also cleans up only non-classname services in the server container Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
c31e4266c7
commit
5be18215fb
|
@ -30,9 +30,6 @@
|
|||
namespace OCA\Encryption\AppInfo;
|
||||
|
||||
use OC\Files\View;
|
||||
use OCA\Encryption\Controller\RecoveryController;
|
||||
use OCA\Encryption\Controller\SettingsController;
|
||||
use OCA\Encryption\Controller\StatusController;
|
||||
use OCA\Encryption\Crypto\Crypt;
|
||||
use OCA\Encryption\Crypto\DecryptAll;
|
||||
use OCA\Encryption\Crypto\EncryptAll;
|
||||
|
@ -128,36 +125,6 @@ class Application extends \OCP\AppFramework\App {
|
|||
public function registerServices() {
|
||||
$container = $this->getContainer();
|
||||
|
||||
$container->registerService(Crypt::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new Crypt($server->getLogger(),
|
||||
$server->getUserSession(),
|
||||
$server->getConfig(),
|
||||
$server->getL10N($c->get('AppName')));
|
||||
});
|
||||
|
||||
$container->registerService(Session::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new Session($server->getSession());
|
||||
}
|
||||
);
|
||||
|
||||
$container->registerService(KeyManager::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
|
||||
return new KeyManager($server->getEncryptionKeyStorage(),
|
||||
$c->get(Crypt::class),
|
||||
$server->getConfig(),
|
||||
$server->getUserSession(),
|
||||
new Session($server->getSession()),
|
||||
$server->getLogger(),
|
||||
$c->get(Util::class),
|
||||
$server->getLockingProvider()
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService(Recovery::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
|
@ -172,55 +139,6 @@ class Application extends \OCP\AppFramework\App {
|
|||
new View());
|
||||
});
|
||||
|
||||
$container->registerService(RecoveryController::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new RecoveryController(
|
||||
$c->get('AppName'),
|
||||
$server->getRequest(),
|
||||
$server->getConfig(),
|
||||
$server->getL10N($c->get('AppName')),
|
||||
$c->get(Recovery::class));
|
||||
});
|
||||
|
||||
$container->registerService(StatusController::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new StatusController(
|
||||
$c->get('AppName'),
|
||||
$server->getRequest(),
|
||||
$server->getL10N($c->get('AppName')),
|
||||
$c->get(Session::class),
|
||||
$server->getEncryptionManager()
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService(SettingsController::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new SettingsController(
|
||||
$c->get('AppName'),
|
||||
$server->getRequest(),
|
||||
$server->getL10N($c->get('AppName')),
|
||||
$server->getUserManager(),
|
||||
$server->getUserSession(),
|
||||
$c->get(KeyManager::class),
|
||||
$c->get(Crypt::class),
|
||||
$c->get(Session::class),
|
||||
$server->getSession(),
|
||||
$c->get(Util::class)
|
||||
);
|
||||
});
|
||||
|
||||
$container->registerService(Setup::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
return new Setup($server->getLogger(),
|
||||
$server->getUserSession(),
|
||||
$c->get(Crypt::class),
|
||||
$c->get(KeyManager::class));
|
||||
});
|
||||
|
||||
$container->registerService(Util::class, function (ContainerInterface $c) {
|
||||
/** @var IServerContainer $server */
|
||||
$server = $c->get(IServerContainer::class);
|
||||
|
@ -251,16 +169,5 @@ class Application extends \OCP\AppFramework\App {
|
|||
);
|
||||
}
|
||||
);
|
||||
|
||||
$container->registerService(DecryptAll::class,function (ContainerInterface $c) {
|
||||
return new DecryptAll(
|
||||
$c->get(Util::class),
|
||||
$c->get(KeyManager::class),
|
||||
$c->get(Crypt::class),
|
||||
$c->get(Session::class),
|
||||
new QuestionHelper()
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,8 @@ use OCP\Dashboard\IDashboardManager;
|
|||
use OCP\Defaults;
|
||||
use OCP\Diagnostics\IEventLogger;
|
||||
use OCP\Diagnostics\IQueryLogger;
|
||||
use OCP\Encryption\IFile;
|
||||
use OCP\Encryption\Keys\IStorage;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Federation\ICloudFederationFactory;
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
|
@ -334,7 +336,9 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
/** @deprecated 19.0.0 */
|
||||
$this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
|
||||
|
||||
$this->registerService('EncryptionFileHelper', function (ContainerInterface $c) {
|
||||
/** @deprecated 21.0.0 */
|
||||
$this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
|
||||
$this->registerService(IFile::class, function (ContainerInterface $c) {
|
||||
$util = new Encryption\Util(
|
||||
new View(),
|
||||
$c->get(IUserManager::class),
|
||||
|
@ -348,7 +352,9 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
);
|
||||
});
|
||||
|
||||
$this->registerService('EncryptionKeyStorage', function (ContainerInterface $c) {
|
||||
/** @deprecated 21.0.0 */
|
||||
$this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
|
||||
$this->registerService(IStorage::class, function (ContainerInterface $c) {
|
||||
$view = new View();
|
||||
$util = new Encryption\Util(
|
||||
$view,
|
||||
|
@ -1427,7 +1433,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
* @deprecated 20.0.0
|
||||
*/
|
||||
public function getEncryptionFilesHelper() {
|
||||
return $this->get('EncryptionFileHelper');
|
||||
return $this->get(IFile::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1435,7 +1441,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
* @deprecated 20.0.0
|
||||
*/
|
||||
public function getEncryptionKeyStorage() {
|
||||
return $this->get('EncryptionKeyStorage');
|
||||
return $this->get(IStorage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue