Provisioning API to IBootstrap

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2021-03-09 20:17:44 +01:00 committed by backportbot[bot]
parent c74cccd12c
commit fa2dc9abc5
1 changed files with 13 additions and 6 deletions

View File

@ -34,20 +34,24 @@ use OC\Group\Manager as GroupManager;
use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware; use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
use OCA\Settings\Mailer\NewUserMailHelper; use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Utility\IControllerMethodReflector; use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCP\Defaults; use OCP\Defaults;
use OCP\IGroupManager; use OCP\IGroupManager;
use OCP\IUser; use OCP\IUser;
use OCP\Util; use OCP\Util;
class Application extends App { class Application extends App implements IBootstrap {
public function __construct(array $urlParams = []) { public function __construct(array $urlParams = []) {
parent::__construct('provisioning_api', $urlParams); parent::__construct('provisioning_api', $urlParams);
}
$container = $this->getContainer(); public function register(IRegistrationContext $context): void {
$server = $container->getServer(); $server = $this->getContainer()->getServer();
$container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { $context->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) {
return new NewUserMailHelper( return new NewUserMailHelper(
$server->query(Defaults::class), $server->query(Defaults::class),
$server->getURLGenerator(), $server->getURLGenerator(),
@ -60,7 +64,7 @@ class Application extends App {
Util::getDefaultEmailAddress('no-reply') Util::getDefaultEmailAddress('no-reply')
); );
}); });
$container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { $context->registerService(ProvisioningApiMiddleware::class, function (SimpleContainer $c) use ($server) {
$user = $server->getUserManager()->get($c['UserId']); $user = $server->getUserManager()->get($c['UserId']);
$isAdmin = false; $isAdmin = false;
$isSubAdmin = false; $isSubAdmin = false;
@ -78,6 +82,9 @@ class Application extends App {
$isSubAdmin $isSubAdmin
); );
}); });
$container->registerMiddleWare('ProvisioningApiMiddleware'); $context->registerMiddleware(ProvisioningApiMiddleware::class);
}
public function boot(IBootContext $context): void {
} }
} }