getVersion method

This commit is contained in:
Yuri Kuznetsov
2025-01-31 21:09:21 +02:00
parent 029331b3b7
commit 489f71ea47
5 changed files with 14 additions and 13 deletions
@@ -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);
}
@@ -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.");
}
@@ -45,4 +45,9 @@ class SystemConfig
{
return (bool) $this->config->get('useCache');
}
public function getVersion(): string
{
return (string) $this->config->get('version');
}
}
@@ -148,7 +148,7 @@ class Manager
return null;
}
$currentVersion = $this->config->get('version');
$currentVersion = $this->systemConfig->getVersion();
if ($currentVersion === 'dev') {
return null;
+2 -2
View File
@@ -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(),
]);
}
}