Initial commit

This commit is contained in:
root
2026-01-19 17:44:46 +01:00
commit 823af8b11d
8721 changed files with 1130846 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Binding\Binding as BindingItem;
use Espo\Core\Binding\EspoBindingLoader;
use Espo\Core\Console\Command\Params;
use Espo\Core\Utils\Module;
class Binding
{
private Module $module;
public function __construct(Module $module)
{
$this->module = $module;
}
public function process(Params $params): string
{
$result = '';
$bindingLoader = new EspoBindingLoader($this->module);
$data = $bindingLoader->load();
$keyList = $data->getGlobalKeyList();
$result .= "Global:\n\n";
foreach ($keyList as $key) {
$result .= $this->printItem($key, $data->getGlobal($key));
}
$contextList = $data->getContextList();
foreach ($contextList as $context) {
$result .= "Context: {$context}\n\n";
$keyList = $data->getContextKeyList($context);
foreach ($keyList as $key) {
$result .= $this->printItem($key, $data->getContext($context, $key));
}
}
return $result;
}
private function printItem(string $key, BindingItem $binding): string
{
$result = '';
$tab = ' ';
$result .= $tab . "Key: {$key}\n";
$type = $binding->getType();
$value = $binding->getValue();
$typeString = [
BindingItem::IMPLEMENTATION_CLASS_NAME => 'Implementation',
BindingItem::CONTAINER_SERVICE => 'Service',
BindingItem::VALUE => 'Value',
BindingItem::CALLBACK => 'Callback',
BindingItem::FACTORY_CLASS_NAME => 'Factory',
][$type];
$result .= $tab . "Type: {$typeString}\n";
if ($type == BindingItem::IMPLEMENTATION_CLASS_NAME || $type == BindingItem::CONTAINER_SERVICE) {
$result .= $tab . "Value: {$value}\n";
}
if ($type == BindingItem::VALUE) {
if (is_string($value) || is_int($value) || is_float($value)) {
$result .= $tab . "Value: {$value}\n";
}
if (is_bool($value)) {
$valueString = $value ? 'true' : 'false';
$result .= $tab . "Value: {$valueString}\n";
}
}
$result .= "\n";
return $result;
}
}

View File

@@ -0,0 +1,101 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Container as ContainerService;
use Espo\Core\Utils\Metadata;
class Container
{
public function __construct(private ContainerService $container, private Metadata $metadata)
{}
public function process(Params $params): string
{
$nameOnly = $params->hasFlag('nameOnly');
$result = '';
$serviceList = [
'injectableFactory',
'config',
'log',
'fileManager',
'dataManager',
'metadata',
'user',
];
/** @var string[] $fileList */
$fileList = scandir('application/Espo/Core/Loaders');
if (file_exists('custom/Espo/Custom/Core/Loaders')) {
$fileList = array_merge($fileList, scandir('custom/Espo/Custom/Core/Loaders') ?: []);
}
foreach ($fileList as $file) {
if (substr($file, -4) === '.php') {
$name = lcfirst(substr($file, 0, -4));
if (!in_array($name, $serviceList) && $this->container->has($name)) {
$serviceList[] = $name;
}
}
}
foreach ($this->metadata->get(['app', 'containerServices']) ?? [] as $name => $data) {
if (!in_array($name, $serviceList)) {
$serviceList[] = $name;
}
}
sort($serviceList);
if ($nameOnly) {
foreach ($serviceList as $name) {
$result .= $name . "\n";
}
return $result;
}
foreach ($serviceList as $name) {
$result .= $name . "\n";
$obj = $this->container->get($name);
$result .= get_class($obj) . "\n";
$result .= "\n";
}
return $result;
}
}

View File

@@ -0,0 +1,68 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\ClassFinder;
use Espo\Core\Job\MetadataProvider;
class Jobs
{
private $classFinder;
private $metadataProvider;
public function __construct(ClassFinder $classFinder, MetadataProvider $metadataProvider)
{
$this->classFinder = $classFinder;
$this->metadataProvider = $metadataProvider;
}
public function process(Params $params): string
{
$result = "Available jobs:\n\n";
$list = array_map(
function ($item) {
return ' ' . $item;
},
array_unique(
array_merge(
array_keys($this->classFinder->getMap('Jobs')),
$this->metadataProvider->getScheduledJobNameList()
)
)
);
asort($list);
return $result . implode("\n", $list) . "\n";
}
}