blob: d9c029d15c239cd378e3ecf7959243df0662ef3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Config;
use OCP\Config\Lexicon\Preset;
use OCP\IConfig;
/**
* tools to maintains configurations
*/
class PresetManager {
private const PRESET_CONFIGKEY = 'config_preset';
private ?Preset $configLexiconPreset = null;
public function __construct(
private readonly IConfig $config,
private readonly ConfigManager $configManager,
) {
}
/**
* store in config.php the new preset
* refresh cached preset
*/
public function setLexiconPreset(Preset $preset): void {
$this->config->setSystemValue(self::PRESET_CONFIGKEY, $preset->value);
$this->configLexiconPreset = $preset;
$this->configManager->clearConfigCaches();
}
/**
* returns currently selected Preset
*/
public function getLexiconPreset(): Preset {
if ($this->configLexiconPreset === null) {
$this->configLexiconPreset = Preset::tryFrom($this->config->getSystemValueInt(self::PRESET_CONFIGKEY, 0)) ?? Preset::NONE;
}
return $this->configLexiconPreset;
}
}
|