nextcloud_groupfolder_files.../lib/Service/SettingsService.php

42 lines
1 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace OCA\GroupfolderFilesystemSnapshots\Service;
use OCA\GroupfolderFilesystemSnapshots\AppInfo\Application;
use OCP\IConfig;
class SettingsService {
private static array $VALID_APP_SETTINGS = ["filesystem_mountpoint_path", "filesystem_snapshots_path"];
public function __construct(private IConfig $config) {
}
public function getAppValues(): array {
$result = [];
foreach(self::$VALID_APP_SETTINGS as $key) {
$result[$key] = $this->config->getAppValue(Application::APP_ID, $key);
}
return $result;
}
public function getAppValue(string $key): string {
if(in_array($key, self::$VALID_APP_SETTINGS)) {
return $this->config->getAppValue(Application::APP_ID, $key);
}
}
public function setAppValue(string $key, string $value): string {
if(in_array($key, self::$VALID_APP_SETTINGS)) {
if($value !== '') {
$this->config->setAppValue(Application::APP_ID, $key, $value);
} else {
$this->config->deleteAppValue(Application::APP_ID, $key);
}
return $value;
}
}
}