Make domain an attribute

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-19 12:06:20 +01:00
parent f737d2f598
commit 5b0b9ef826
3 changed files with 15 additions and 14 deletions

View file

@ -91,7 +91,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
$skip_domain_validation = isset($params['skip_domain_validation']);
return $view->render($response, 'containers.twig', [
'domain' => $configurationManager->GetDomain(),
'domain' => $configurationManager->domain,
'apache_port' => $configurationManager->GetApachePort(),
'borg_backup_host_location' => $configurationManager->GetBorgBackupHostLocation(),
'borg_remote_repo' => $configurationManager->GetBorgRemoteRepo(),

View file

@ -257,7 +257,7 @@ readonly class DockerController {
public function StartDomaincheckContainer() : void
{
# Don't start if domain is already set
if ($this->configurationManager->GetDomain() !== '' || $this->configurationManager->wasStartButtonClicked) {
if ($this->configurationManager->domain !== '' || $this->configurationManager->wasStartButtonClicked) {
return;
}

View file

@ -104,6 +104,11 @@ class ConfigurationManager
set { $this->set('isFulltextsearchEnabled', ($this->isSeccompDisabled() && $value)); }
}
public string $domain {
get => $this->get('domain', '');
set { $this->SetDomain($value); }
}
public function GetConfig() : array
{
if ($this->config === [] && file_exists(DataConst::GetConfigFile()))
@ -241,6 +246,8 @@ class ConfigurationManager
/**
* @throws InvalidSettingConfigurationException
*
* We can't turn this into a private validation method because of the second argument.
*/
public function SetDomain(string $domain, bool $skipDomainValidation) : void {
// Validate that at least one dot is contained
@ -346,25 +353,19 @@ class ConfigurationManager
}
}
// Write domain
$config = $this->GetConfig();
$config['domain'] = $domain;
// Reset the borg restore password when setting the domain
$config['borg_restore_password'] = '';
$this->WriteConfig($config);
}
public function GetDomain() : string {
$config = $this->GetConfig();
if(!isset($config['domain'])) {
$config['domain'] = '';
}
return $config['domain'];
$this->setMultiple(function ($confManager) use ($domain) {
// Write domain
// Don't set the domain via the attribute, or we create a loop.
$confManager->set('domain', $domain);
});
}
public function GetBaseDN() : string {
$domain = $this->GetDomain();
$domain = $this->domain;
if ($domain === "") {
return "";
}