diff options
author | Louis Chemineau <louis@chmn.me> | 2024-06-27 11:33:21 +0200 |
---|---|---|
committer | Louis <louis@chmn.me> | 2024-07-01 13:45:09 +0200 |
commit | 39fd19f1d68037edce9080ac3af11bb9ff9320c5 (patch) | |
tree | ed9929992357ce04456989850b293c495bb41be4 /apps/encryption | |
parent | beececf66068f57c416225efcde9b44ce5c2e835 (diff) | |
download | nextcloud-server-39fd19f1d68037edce9080ac3af11bb9ff9320c5.tar.gz nextcloud-server-39fd19f1d68037edce9080ac3af11bb9ff9320c5.zip |
refactor(encryption): Migrate app.php to Application.php
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/appinfo/app.php | 21 | ||||
-rw-r--r-- | apps/encryption/lib/AppInfo/Application.php | 36 |
2 files changed, 30 insertions, 27 deletions
diff --git a/apps/encryption/appinfo/app.php b/apps/encryption/appinfo/app.php deleted file mode 100644 index da838c3f280..00000000000 --- a/apps/encryption/appinfo/app.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/** - * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2016 ownCloud, Inc. - * SPDX-License-Identifier: AGPL-3.0-only - */ -namespace OCA\Encryption\AppInfo; - -\OCP\Util::addscript('encryption', 'encryption'); - -$encryptionManager = \OC::$server->getEncryptionManager(); -$encryptionSystemReady = $encryptionManager->isReady(); - -/** @var Application $app */ -$app = \OC::$server->query(Application::class); -if ($encryptionSystemReady) { - $app->registerEncryptionModule($encryptionManager); - $app->registerHooks(\OC::$server->getConfig()); - $app->setUp($encryptionManager); -} diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php index fa765de4248..d3f7eb44145 100644 --- a/apps/encryption/lib/AppInfo/Application.php +++ b/apps/encryption/lib/AppInfo/Application.php @@ -18,16 +18,40 @@ use OCA\Encryption\Recovery; use OCA\Encryption\Session; use OCA\Encryption\Users\Setup; use OCA\Encryption\Util; +use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Encryption\IManager; use OCP\IConfig; use Psr\Log\LoggerInterface; -class Application extends \OCP\AppFramework\App { - /** - * @param array $urlParams - */ - public function __construct($urlParams = []) { - parent::__construct('encryption', $urlParams); +class Application extends App implements IBootstrap { + public const APP_ID = 'encryption'; + + public function __construct(array $urlParams = []) { + parent::__construct(self::APP_ID, $urlParams); + } + + public function register(IRegistrationContext $context): void { + } + + public function boot(IBootContext $context): void { + \OCP\Util::addScript(self::APP_ID, 'encryption'); + + $context->injectFn(function (IManager $encryptionManager) use ($context) { + if (!($encryptionManager instanceof \OC\Encryption\Manager)) { + return; + } + + if (!$encryptionManager->isReady()) { + return; + } + + $context->injectFn($this->registerEncryptionModule(...)); + $context->injectFn($this->registerHooks(...)); + $context->injectFn($this->setUp(...)); + }); } public function setUp(IManager $encryptionManager) { |