Skip to content

Commit c89087d

Browse files
committed
refactor(encryption): Migrate app.php to Application.php
Signed-off-by: Louis Chemineau <[email protected]>
1 parent 9b05759 commit c89087d

2 files changed

Lines changed: 31 additions & 27 deletions

File tree

apps/encryption/appinfo/app.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

apps/encryption/lib/AppInfo/Application.php

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OCA\Encryption\AppInfo;
99

10+
use Closure;
1011
use OCA\Encryption\Crypto\Crypt;
1112
use OCA\Encryption\Crypto\DecryptAll;
1213
use OCA\Encryption\Crypto\EncryptAll;
@@ -18,16 +19,40 @@
1819
use OCA\Encryption\Session;
1920
use OCA\Encryption\Users\Setup;
2021
use OCA\Encryption\Util;
22+
use OCP\AppFramework\App;
23+
use OCP\AppFramework\Bootstrap\IBootContext;
24+
use OCP\AppFramework\Bootstrap\IBootstrap;
25+
use OCP\AppFramework\Bootstrap\IRegistrationContext;
2126
use OCP\Encryption\IManager;
2227
use OCP\IConfig;
2328
use Psr\Log\LoggerInterface;
2429

25-
class Application extends \OCP\AppFramework\App {
26-
/**
27-
* @param array $urlParams
28-
*/
29-
public function __construct($urlParams = []) {
30-
parent::__construct('encryption', $urlParams);
30+
class Application extends App implements IBootstrap {
31+
public const APP_ID = 'encryption';
32+
33+
public function __construct(array $urlParams = []) {
34+
parent::__construct(self::APP_ID, $urlParams);
35+
}
36+
37+
public function register(IRegistrationContext $context): void {
38+
}
39+
40+
public function boot(IBootContext $context): void {
41+
\OCP\Util::addScript('encryption', 'encryption');
42+
43+
$context->injectFn(function (IManager $encryptionManager) use ($context) {
44+
if (!($encryptionManager instanceof \OC\Encryption\Manager)) {
45+
return;
46+
}
47+
48+
if (!$encryptionManager->isReady()) {
49+
return;
50+
}
51+
52+
$context->injectFn(Closure::fromCallable([$this, 'registerEncryptionModule']));
53+
$context->injectFn(Closure::fromCallable([$this, 'registerHooks']));
54+
$context->injectFn(Closure::fromCallable([$this, 'setUp']));
55+
});
3156
}
3257

3358
public function setUp(IManager $encryptionManager) {

0 commit comments

Comments
 (0)