EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
App info provider, versions providers
Yurii83c09f37daac
diff --git a/application/Espo/Classes/AppInfo/Binding.php b/application/Espo/Classes/AppInfo/Binding.phpindex 69961c471e..58fc6b4f25 100644--- a/application/Espo/Classes/AppInfo/Binding.php+++ b/application/Espo/Classes/AppInfo/Binding.php@@ -33,17 +33,15 @@ use Espo\Core\Binding\Binding as BindingItem;use Espo\Core\Binding\EspoBindingLoader;use Espo\Core\Console\Command\Params;use Espo\Core\Utils\Module;+use Espo\Tools\ConsoleAppInfo\InfoProvider;-class Binding+class Binding implements InfoProvider{- private Module $module;- public function __construct(Module $module)- {- $this->module = $module;- }+ public function __construct(private Module $module)+ {}- public function process(Params $params): string+ public function get(Params $params): string{$result = '';diff --git a/application/Espo/Classes/AppInfo/Container.php b/application/Espo/Classes/AppInfo/Container.phpindex db608b1a3d..96b6539495 100644--- a/application/Espo/Classes/AppInfo/Container.php+++ b/application/Espo/Classes/AppInfo/Container.php@@ -32,13 +32,14 @@ namespace Espo\Classes\AppInfo;use Espo\Core\Console\Command\Params;use Espo\Core\Container as ContainerService;use Espo\Core\Utils\Metadata;+use Espo\Tools\ConsoleAppInfo\InfoProvider;-class Container+class Container implements InfoProvider{public function __construct(private ContainerService $container, private Metadata $metadata){}- public function process(Params $params): string+ public function get(Params $params): string{$nameOnly = $params->hasFlag('nameOnly');diff --git a/application/Espo/Classes/AppInfo/CoreVersion.php b/application/Espo/Classes/AppInfo/CoreVersion.phpnew file mode 100644index 0000000000..9a2c1a4eb2--- /dev/null+++ b/application/Espo/Classes/AppInfo/CoreVersion.php@@ -0,0 +1,49 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program 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 Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Classes\AppInfo;++use Espo\Core\Console\Command\Params;+use Espo\Core\Upgrades\Migration\VersionDataProvider;+use Espo\Tools\ConsoleAppInfo\InfoProvider;++/**+ * @noinspection PhpUnused+ */+class CoreVersion implements InfoProvider+{+ public function __construct(+ private VersionDataProvider $versionDataProvider,+ ) {}++ public function get(Params $params): string+ {+ return $this->versionDataProvider->getTargetVersion();+ }+}diff --git a/application/Espo/Classes/AppInfo/Jobs.php b/application/Espo/Classes/AppInfo/Jobs.phpindex 3adc44863c..9937f06586 100644--- a/application/Espo/Classes/AppInfo/Jobs.php+++ b/application/Espo/Classes/AppInfo/Jobs.php@@ -32,20 +32,17 @@ namespace Espo\Classes\AppInfo;use Espo\Core\Console\Command\Params;use Espo\Core\Utils\ClassFinder;use Espo\Core\Job\MetadataProvider;+use Espo\Tools\ConsoleAppInfo\InfoProvider;-class Jobs+class Jobs implements InfoProvider{- private $classFinder;- private $metadataProvider;+ public function __construct(+ private ClassFinder $classFinder,+ private MetadataProvider $metadataProvider,+ ) {}- public function __construct(ClassFinder $classFinder, MetadataProvider $metadataProvider)- {- $this->classFinder = $classFinder;- $this->metadataProvider = $metadataProvider;- }-- public function process(Params $params): string+ public function get(Params $params): string{$result = "Available jobs:\n\n";diff --git a/application/Espo/Classes/AppInfo/Version.php b/application/Espo/Classes/AppInfo/Version.phpnew file mode 100644index 0000000000..a9d56c87ef--- /dev/null+++ b/application/Espo/Classes/AppInfo/Version.php@@ -0,0 +1,46 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program 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 Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Classes\AppInfo;++use Espo\Core\Console\Command\Params;+use Espo\Core\Utils\Config\SystemConfig;+use Espo\Tools\ConsoleAppInfo\InfoProvider;++class Version implements InfoProvider+{+ public function __construct(+ private SystemConfig $systemConfig,+ ) {}++ public function get(Params $params): string+ {+ return $this->systemConfig->getVersion();+ }+}diff --git a/application/Espo/Core/Console/Commands/AppInfo.php b/application/Espo/Core/Console/Commands/AppInfo.phpindex 6579d7695a..2fe3569a96 100644--- a/application/Espo/Core/Console/Commands/AppInfo.php+++ b/application/Espo/Core/Console/Commands/AppInfo.php@@ -35,6 +35,7 @@ use Espo\Core\Console\IO;use Espo\Core\InjectableFactory;use Espo\Core\Utils\File\Manager as FileManager;use Espo\Core\Utils\Util;+use Espo\Tools\ConsoleAppInfo\InfoProvider;/*** @noinspection PhpUnused@@ -57,7 +58,7 @@ class AppInfo implements Command);foreach ($typeList as $type) {- if ($params->hasFlag(Util::camelCaseToHyphen($type))) {+ if ($params->hasFlag($type)) {$this->processType($io, $type, $params);return;@@ -83,17 +84,13 @@ class AppInfo implements Commandprotected function processType(IO $io, string $type, Params $params): void{- /** @var class-string $className */+ /** @var class-string<InfoProvider> $className */$className = 'Espo\\Classes\\AppInfo\\' . ucfirst($type);- $obj = $this->injectableFactory->create($className);+ $provider = $this->injectableFactory->create($className);- // @todo Use inteface.- assert(method_exists($obj, 'process'));+ $result = $provider->get($params);- $result = $obj->process($params);-- $io->writeLine('');$io->write($result);$io->writeLine("");}diff --git a/application/Espo/Tools/ConsoleAppInfo/InfoProvider.php b/application/Espo/Tools/ConsoleAppInfo/InfoProvider.phpnew file mode 100644index 0000000000..6ff4988c99--- /dev/null+++ b/application/Espo/Tools/ConsoleAppInfo/InfoProvider.php@@ -0,0 +1,40 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program 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 Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Tools\ConsoleAppInfo;++use Espo\Core\Console\Command\Params;++/**+ * @since 10.0.0+ */+interface InfoProvider+{+ public function get(Params $params): string;+}