diff --git a/application/Espo/Core/Console/Commands/Version.php b/application/Espo/Core/Console/Commands/Version.php index be3253fe1d..811d37791a 100644 --- a/application/Espo/Core/Console/Commands/Version.php +++ b/application/Espo/Core/Console/Commands/Version.php @@ -36,16 +36,12 @@ use Espo\Core\Utils\Config; class Version implements Command { - public function __construct(private Config $config) + public function __construct(private Config\SystemConfig $config) {} public function run(Params $params, IO $io): void { - $version = $this->config->get('version'); - - if (is_null($version)) { - return; - } + $version = $this->config->getVersion(); $io->writeLine($version); } diff --git a/application/Espo/Core/Upgrades/Migration/VersionDataProvider.php b/application/Espo/Core/Upgrades/Migration/VersionDataProvider.php index 24a1237c1c..462b7d8155 100644 --- a/application/Espo/Core/Upgrades/Migration/VersionDataProvider.php +++ b/application/Espo/Core/Upgrades/Migration/VersionDataProvider.php @@ -38,15 +38,15 @@ class VersionDataProvider private string $defaultConfigPath = 'application/Espo/Resources/defaults/config.php'; public function __construct( - private Config $config, - private Manager $fileManager + private Manager $fileManager, + private Config\SystemConfig $systemConfig, ) {} public function getPreviousVersion(): string { - $version = $this->config->get('version'); + $version = $this->systemConfig->getVersion(); - if (!is_string($version) || !$version) { + if (!$version) { throw new RuntimeException("No or bad 'version' in config."); } diff --git a/application/Espo/Core/Utils/Config/SystemConfig.php b/application/Espo/Core/Utils/Config/SystemConfig.php index be8dd92353..c92eac916c 100644 --- a/application/Espo/Core/Utils/Config/SystemConfig.php +++ b/application/Espo/Core/Utils/Config/SystemConfig.php @@ -45,4 +45,9 @@ class SystemConfig { return (bool) $this->config->get('useCache'); } + + public function getVersion(): string + { + return (string) $this->config->get('version'); + } } diff --git a/application/Espo/Tools/AdminNotifications/Manager.php b/application/Espo/Tools/AdminNotifications/Manager.php index b064c4bb6b..dbcd1dac7a 100644 --- a/application/Espo/Tools/AdminNotifications/Manager.php +++ b/application/Espo/Tools/AdminNotifications/Manager.php @@ -148,7 +148,7 @@ class Manager return null; } - $currentVersion = $this->config->get('version'); + $currentVersion = $this->systemConfig->getVersion(); if ($currentVersion === 'dev') { return null; diff --git a/application/Espo/Tools/App/Api/GetAbout.php b/application/Espo/Tools/App/Api/GetAbout.php index 748ff7e4a2..cfddfa2c53 100644 --- a/application/Espo/Tools/App/Api/GetAbout.php +++ b/application/Espo/Tools/App/Api/GetAbout.php @@ -43,7 +43,7 @@ class GetAbout implements Action { public function __construct( private FileReader $fileReader, - private Config $config + private Config\SystemConfig $systemConfig, ) {} public function process(Request $request): Response @@ -52,7 +52,7 @@ class GetAbout implements Action return ResponseComposer::json([ 'text' => $text, - 'version' => $this->config->get('version'), + 'version' => $this->systemConfig->getVersion(), ]); } }