Skip to content

Commit c9c31b1

Browse files
committed
move things to the register phase
1 parent 9debc68 commit c9c31b1

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

solid/lib/AppInfo/Application.php

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use OC\Server;
1111

1212
use OCA\Solid\Service\UserService;
13+
use OCA\Solid\Service\SolidWebhookService;
14+
use OCA\Solid\Db\SolidWebhookMapper;
1315
use OCA\Solid\WellKnown\OpenIdConfigurationHandler;
1416
use OCA\Solid\WellKnown\SolidHandler;
1517
use OCA\Solid\Middleware\SolidCorsMiddleware;
@@ -33,33 +35,12 @@ class Application extends App implements IBootstrap {
3335
public function __construct(array $urlParams = []) {
3436
parent::__construct(self::APP_ID, $urlParams);
3537

36-
$container = $this->getContainer();
37-
38-
$container->registerService(SolidCorsMiddleware::class, function($c): SolidCorsMiddleware {
39-
return new SolidCorsMiddleware(
40-
$c->get(IRequest::class)
41-
);
42-
});
43-
44-
// executed in the order that it is registered
45-
$container->registerMiddleware(SolidCorsMiddleware::class);
46-
47-
$container->registerService(SolidWebhookService::class, function($c): SolidWebhookService {
48-
return new SolidWebhookService(
49-
$c->query(SolidWebhookMapper::class)
50-
);
51-
});
52-
53-
$container->registerService(SolidWebhookMapper::class, function($c): SolidWebhookMapper {
54-
return new SolidWebhookMapper(
55-
$c->get(IDBConnection::class)
56-
);
57-
});
5838
}
5939

6040
public function register(IRegistrationContext $context): void {
6141
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\OpenIdConfigurationHandler::class);
6242
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\SolidHandler::class);
43+
$context->registerMiddleware(SolidCorsMiddleware::class);
6344

6445
/**
6546
* Core class wrappers
@@ -79,6 +60,19 @@ public function register(IRegistrationContext $context): void {
7960
$context->registerService('User', function($c) {
8061
return $c->query('UserSession')->getUser();
8162
});
63+
64+
/* webhook DB services */
65+
$context->registerService(SolidWebhookService::class, function($c): SolidWebhookService {
66+
return new SolidWebhookService(
67+
$c->query(SolidWebhookMapper::class)
68+
);
69+
});
70+
71+
$context->registerService(SolidWebhookMapper::class, function($c): SolidWebhookMapper {
72+
return new SolidWebhookMapper(
73+
$c->get(IDBConnection::class)
74+
);
75+
});
8276
}
8377

8478
public function boot(IBootContext $context): void {

0 commit comments

Comments
 (0)