diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2024-01-11 15:32:58 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2024-01-15 15:45:13 -0100 |
commit | f7d0c74b1003af6c47dd6ec74f4ef904a2681d62 (patch) | |
tree | a0bfe1934fbec0ccf6651824589a0e67ae4f9d9f /apps/provisioning_api/lib | |
parent | e5ef58b7b9b8f7a232666df17d286d43fb4d1201 (diff) | |
download | nextcloud-server-f7d0c74b1003af6c47dd6ec74f4ef904a2681d62.tar.gz nextcloud-server-f7d0c74b1003af6c47dd6ec74f4ef904a2681d62.zip |
lazy AppConfig
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r-- | apps/provisioning_api/lib/Controller/AppConfigController.php | 65 |
1 files changed, 19 insertions, 46 deletions
diff --git a/apps/provisioning_api/lib/Controller/AppConfigController.php b/apps/provisioning_api/lib/Controller/AppConfigController.php index 798daedaf6b..ea862550e2d 100644 --- a/apps/provisioning_api/lib/Controller/AppConfigController.php +++ b/apps/provisioning_api/lib/Controller/AppConfigController.php @@ -27,12 +27,12 @@ declare(strict_types=1); */ namespace OCA\Provisioning_API\Controller; +use OC\AppConfig; use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; use OCP\IAppConfig; -use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; use OCP\IRequest; @@ -42,46 +42,17 @@ use OCP\Settings\IDelegatedSettings; use OCP\Settings\IManager; class AppConfigController extends OCSController { - - /** @var IConfig */ - protected $config; - - /** @var IAppConfig */ - protected $appConfig; - - /** @var IUserSession */ - private $userSession; - - /** @var IL10N */ - private $l10n; - - /** @var IGroupManager */ - private $groupManager; - - /** @var IManager */ - private $settingManager; - - /** - * @param string $appName - * @param IRequest $request - * @param IConfig $config - * @param IAppConfig $appConfig - */ - public function __construct(string $appName, + public function __construct( + string $appName, IRequest $request, - IConfig $config, - IAppConfig $appConfig, - IUserSession $userSession, - IL10N $l10n, - IGroupManager $groupManager, - IManager $settingManager) { + /** @var AppConfig */ + private IAppConfig $appConfig, + private IUserSession $userSession, + private IL10N $l10n, + private IGroupManager $groupManager, + private IManager $settingManager, + ) { parent::__construct($appName, $request); - $this->config = $config; - $this->appConfig = $appConfig; - $this->userSession = $userSession; - $this->l10n = $l10n; - $this->groupManager = $groupManager; - $this->settingManager = $settingManager; } /** @@ -113,7 +84,7 @@ class AppConfigController extends OCSController { return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN); } return new DataResponse([ - 'data' => $this->config->getAppKeys($app), + 'data' => $this->appConfig->getKeys($app), ]); } @@ -134,9 +105,10 @@ class AppConfigController extends OCSController { } catch (\InvalidArgumentException $e) { return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN); } - return new DataResponse([ - 'data' => $this->config->getAppValue($app, $key, $defaultValue), - ]); + + /** @psalm-suppress InternalMethod */ + $value = $this->appConfig->getValueMixed($app, $key, $defaultValue, null); + return new DataResponse(['data' => $value]); } /** @@ -171,7 +143,8 @@ class AppConfigController extends OCSController { return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN); } - $this->config->setAppValue($app, $key, $value); + /** @psalm-suppress InternalMethod */ + $this->appConfig->setValueMixed($app, $key, $value); return new DataResponse(); } @@ -195,7 +168,7 @@ class AppConfigController extends OCSController { return new DataResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_FORBIDDEN); } - $this->config->deleteAppValue($app, $key); + $this->appConfig->deleteKey($app, $key); return new DataResponse(); } @@ -231,7 +204,7 @@ class AppConfigController extends OCSController { if ($app === 'files' && $key === 'default_quota' && $value === 'none' - && $this->config->getAppValue('files', 'allow_unlimited_quota', '1') === '0') { + && $this->appConfig->getValueInt('files', 'allow_unlimited_quota', 1) === 0) { throw new \InvalidArgumentException('The given key can not be set, unlimited quota is forbidden on this instance'); } } |