2024-07-30 19:25:11 +02:00

40 lines
1.1 KiB
PHP

<?
namespace OCA\PrideFlags\Settings;
use OCA\PrideFlags\AppConstants;
use OCP\IConfig;
class AppSettings implements JsonSerializable {
public const FOLDER_VARIANT = 'folderVariant';
public const BUTTON_VARIANT = 'buttonVariant';
public function __construct(private IConfig $config) {
}
public function getStringSetting(string $key, string $default = ''): string {
return $this->config->getAppValue(AppConstants::APP_ID, $key) ?: $default;
}
public function setStringSetting(string $key, string $value): string {
return $this->config->getAppValue(AppConstants::APP_ID, $key, $value);
}
public function getAll(): JsonSerializable {
return [
AppSettings::FOLDER_VARIANT => $this->getStringSetting(AppSettings::FOLDER_VARIANT, 'pride'),
AppSettings::BUTTON_VARIANT => $this->getStringSetting(AppSettings::BUTTON_VARIANT, 'trans'),
]
}
public function set($folder, $button): JsonSerializable {
$this->setStringSetting(AppSettings::FOLDER_VARIANT, $folder);
$this->setStringSetting(AppSettings::BUTTON_VARIANT, $button);
return $this->getAll();
}
public function jsonSerialize(): array {
return $this->getAll();
}
}