You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/lib/private/Config/PresetManager.php

48 lines
1.1 KiB

<?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;
}
}