nextcloud/apps/settings/lib/SetupChecks/ServerIdConfig.php
Côme Chilliet 1ab09ec753
chore: Apply new coding standard to all files
The diff can be checked using: git diff --ignore-all-space --ignore-blank-lines
To see only the changes not related to blank lines.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-06-01 13:46:39 +02:00

60 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\SetupChecks;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
use Override;
final class ServerIdConfig implements ISetupCheck {
public function __construct(
private readonly IL10N $l10n,
private readonly IConfig $config,
private readonly IURLGenerator $urlGenerator,
) {
}
#[Override]
public function getName(): string {
return $this->l10n->t('Configuration server ID');
}
#[Override]
public function getCategory(): string {
return 'config';
}
#[Override]
public function run(): SetupResult {
$serverid = $this->config->getSystemValueInt('serverid', PHP_INT_MIN);
$linkToDoc = $this->urlGenerator->linkToDocs('admin-update');
if ($serverid === PHP_INT_MIN) {
return SetupResult::info(
$this->l10n->t(
'Server identifier isnt configured. It is recommended if your Nextcloud instance is running on several PHP servers. Add a server ID in your configuration.',
),
$linkToDoc,
);
}
if ($serverid < 0 || $serverid > 511) {
return SetupResult::error(
$this->l10n->t('"%d" is not a valid server identifier. It must be between 0 and 511.', [$serverid]),
$linkToDoc,
);
}
return SetupResult::success($this->l10n->t('Server identifier is configured and valid.'));
}
}