Files
sysPass/lib/SP/Core/Bootstrap/UpgradeConfigChecker.php
Rubén D 5e1f4be413 chore: Bootstrap refactoring
Signed-off-by: Rubén D <nuxsmin@syspass.org>
2024-04-20 12:08:01 +02:00

56 lines
1.7 KiB
PHP

<?php
/*
* sysPass
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2024, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
* sysPass is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sysPass is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Core\Bootstrap;
use SP\Domain\Config\Ports\ConfigDataInterface;
use SP\Domain\Config\Ports\UpgradeConfigService;
use SP\Domain\Config\Services\UpgradeConfig;
use SP\Domain\Upgrade\Services\UpgradeUtil;
/**
* Upgrade the config whenever is needed
*/
readonly class UpgradeConfigChecker
{
public function __construct(
private UpgradeConfigService $upgradeConfigService,
private ConfigDataInterface $configData
) {
}
/**
* Comprobar la versión de configuración y actualizarla
*/
public function checkConfigVersion(): void
{
$configVersion = UpgradeUtil::fixVersionNumber($this->configData->getConfigVersion());
if ($this->configData->isInstalled() && UpgradeConfig::needsUpgrade($configVersion)) {
$this->upgradeConfigService->upgrade($configVersion, $this->configData);
}
}
}