Fix some psalm warnings

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-03-10 12:20:45 +01:00
parent e5b1d59dfd
commit a1e5090b3f
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 22 additions and 17 deletions

View File

@ -28,8 +28,6 @@
namespace OCA\Provisioning_API\AppInfo;
use OC\AppFramework\Utility\SimpleContainer;
use OC\AppFramework\Utility\TimeFactory;
use OC\Group\Manager as GroupManager;
use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
use OCA\Settings\Mailer\NewUserMailHelper;
@ -38,10 +36,19 @@ use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Mail\IMailer;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Util;
use Psr\Container\ContainerInterface;
class Application extends App implements IBootstrap {
public function __construct(array $urlParams = []) {
@ -49,35 +56,33 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
$server = $this->getContainer()->getServer();
$context->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) {
$context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) {
return new NewUserMailHelper(
$server->query(Defaults::class),
$server->getURLGenerator(),
$server->getL10NFactory(),
$server->getMailer(),
$server->getSecureRandom(),
new TimeFactory(),
$server->getConfig(),
$server->getCrypto(),
$c->get(Defaults::class),
$c->get(IURLGenerator::class),
$c->get(IFactory::class),
$c->get(IMailer::class),
$c->get(ISecureRandom::class),
$c->get(ITimeFactory::class),
$c->get(IConfig::class),
$c->get(ICrypto::class),
Util::getDefaultEmailAddress('no-reply')
);
});
$context->registerService(ProvisioningApiMiddleware::class, function (SimpleContainer $c) use ($server) {
$user = $server->getUserManager()->get($c['UserId']);
$context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) {
$user = $c->get(IUserManager::class)->get($c->get('UserId'));
$isAdmin = false;
$isSubAdmin = false;
if ($user instanceof IUser) {
$groupManager = $server->get(IGroupManager::class);
$groupManager = $c->get(IGroupManager::class);
assert($groupManager instanceof GroupManager);
$isAdmin = $groupManager->isAdmin($user->getUID());
$isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user);
}
return new ProvisioningApiMiddleware(
$c->query(IControllerMethodReflector::class),
$c->get(IControllerMethodReflector::class),
$isAdmin,
$isSubAdmin
);