system config
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Acl;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -91,10 +91,10 @@ class GlobalRestriction
|
||||
private Metadata $metadata,
|
||||
private DataCache $dataCache,
|
||||
private FieldUtil $fieldUtil,
|
||||
Config $config
|
||||
SystemConfig $systemConfig,
|
||||
) {
|
||||
|
||||
$useCache = $config->get('useCache');
|
||||
$useCache = $systemConfig->useCache();
|
||||
|
||||
if ($useCache && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var stdClass $cachedData */
|
||||
|
||||
@@ -57,14 +57,14 @@ class Map
|
||||
public function __construct(
|
||||
Table $table,
|
||||
private DataBuilder $dataBuilder,
|
||||
private Config $config,
|
||||
private DataCache $dataCache,
|
||||
CacheKeyProvider $cacheKeyProvider
|
||||
CacheKeyProvider $cacheKeyProvider,
|
||||
Config\SystemConfig $systemConfig,
|
||||
) {
|
||||
|
||||
$this->cacheKey = $cacheKeyProvider->get();
|
||||
|
||||
if ($this->config->get('useCache') && $this->dataCache->has($this->cacheKey)) {
|
||||
if ($systemConfig->useCache() && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var stdClass $cachedData */
|
||||
$cachedData = $this->dataCache->get($this->cacheKey);
|
||||
|
||||
@@ -72,7 +72,7 @@ class Map
|
||||
} else {
|
||||
$this->data = $this->dataBuilder->build($table);
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($systemConfig->useCache()) {
|
||||
$this->dataCache->store($this->cacheKey, $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Acl\Table;
|
||||
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Entities\User;
|
||||
|
||||
use Espo\Core\Acl\FieldData;
|
||||
@@ -37,7 +38,6 @@ use Espo\Core\Acl\Table;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use stdClass;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -96,7 +96,7 @@ class DefaultTable implements Table
|
||||
private RoleListProvider $roleListProvider,
|
||||
CacheKeyProvider $cacheKeyProvider,
|
||||
protected User $user,
|
||||
Config $config,
|
||||
SystemConfig $systemConfig,
|
||||
protected Metadata $metadata,
|
||||
DataCache $dataCache,
|
||||
) {
|
||||
@@ -116,7 +116,7 @@ class DefaultTable implements Table
|
||||
|
||||
$this->cacheKey = $cacheKeyProvider->get();
|
||||
|
||||
if ($config->get('useCache') && $dataCache->has($this->cacheKey)) {
|
||||
if ($systemConfig->useCache() && $dataCache->has($this->cacheKey)) {
|
||||
/** @var stdClass $cachedData */
|
||||
$cachedData = $dataCache->get($this->cacheKey);
|
||||
|
||||
@@ -124,7 +124,7 @@ class DefaultTable implements Table
|
||||
} else {
|
||||
$this->load();
|
||||
|
||||
if ($config->get('useCache')) {
|
||||
if ($systemConfig->useCache()) {
|
||||
$dataCache->store($this->cacheKey, $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Espo\Core\Api;
|
||||
|
||||
use Espo\Core\Api\Route\RouteParamsFetcher;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\Route as RouteUtil;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
@@ -54,7 +54,7 @@ class Starter
|
||||
private RouteParamsFetcher $routeParamsFetcher,
|
||||
private MiddlewareProvider $middlewareProvider,
|
||||
private Log $log,
|
||||
private Config $config,
|
||||
private SystemConfig $systemConfig,
|
||||
?string $routeCacheFile = null
|
||||
) {
|
||||
$this->routeCacheFile = $routeCacheFile ?? $this->routeCacheFile;
|
||||
@@ -64,7 +64,7 @@ class Starter
|
||||
{
|
||||
$slim = SlimAppFactory::create();
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($this->systemConfig->useCache()) {
|
||||
$slim->getRouteCollector()->setCacheFile($this->routeCacheFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use Espo\Core\Authentication\Jwt\Exceptions\UnsupportedKey;
|
||||
use Espo\Core\Authentication\Jwt\Key;
|
||||
use Espo\Core\Authentication\Jwt\KeyFactory;
|
||||
use Espo\Core\Field\DateTime;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Core\Utils\Log;
|
||||
@@ -48,10 +48,10 @@ class KeysProvider
|
||||
|
||||
public function __construct(
|
||||
private DataCache $dataCache,
|
||||
private Config $config,
|
||||
private ConfigDataProvider $configDataProvider,
|
||||
private KeyFactory $factory,
|
||||
private Log $log
|
||||
private Log $log,
|
||||
private SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ class KeysProvider
|
||||
*/
|
||||
private function getRawFromCache(): ?array
|
||||
{
|
||||
if (!$this->config->get('useCache')) {
|
||||
if (!$this->systemConfig->useCache()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class KeysProvider
|
||||
*/
|
||||
private function storeRawToCache(array $raw): void
|
||||
{
|
||||
if (!$this->config->get('useCache')) {
|
||||
if (!$this->systemConfig->useCache()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Espo\Core;
|
||||
|
||||
use Espo\Core\Hook\GeneralInvoker;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Log;
|
||||
@@ -72,11 +72,11 @@ class HookManager
|
||||
private InjectableFactory $injectableFactory,
|
||||
private FileManager $fileManager,
|
||||
private Metadata $metadata,
|
||||
private Config $config,
|
||||
private DataCache $dataCache,
|
||||
private Log $log,
|
||||
private PathProvider $pathProvider,
|
||||
private GeneralInvoker $generalInvoker
|
||||
private GeneralInvoker $generalInvoker,
|
||||
private SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ class HookManager
|
||||
|
||||
private function loadHooks(): void
|
||||
{
|
||||
if ($this->config->get('useCache') && $this->dataCache->has($this->cacheKey)) {
|
||||
if ($this->systemConfig->useCache() && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var array<string, array<string, mixed>> $cachedData */
|
||||
$cachedData = $this->dataCache->get($this->cacheKey);
|
||||
|
||||
@@ -166,7 +166,7 @@ class HookManager
|
||||
|
||||
$this->data = $this->sortHooks($data);
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($this->systemConfig->useCache()) {
|
||||
$this->dataCache->store($this->cacheKey, $this->data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ use Espo\Core\Container\Loader;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Language as LanguageService;
|
||||
|
||||
use Espo\Entities\Preferences;
|
||||
|
||||
class Language implements Loader
|
||||
@@ -41,14 +40,15 @@ class Language implements Loader
|
||||
public function __construct(
|
||||
private InjectableFactory $injectableFactory,
|
||||
private Config $config,
|
||||
private Preferences $preferences
|
||||
private Preferences $preferences,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
public function load(): LanguageService
|
||||
{
|
||||
return $this->injectableFactory->createWith(LanguageService::class, [
|
||||
'language' => LanguageService::detectLanguage($this->config, $this->preferences),
|
||||
'useCache' => $this->config->get('useCache') ?? false,
|
||||
'useCache' => $this->systemConfig->useCache(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ use Espo\Core\ApplicationState;
|
||||
use Espo\Core\Portal\Utils\Route as RouteUtil;
|
||||
use Espo\Core\Api\RouteProcessor;
|
||||
use Espo\Core\Api\Route\RouteParamsFetcher;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
class Starter extends StarterBase
|
||||
@@ -46,7 +46,7 @@ class Starter extends StarterBase
|
||||
RouteParamsFetcher $routeParamsFetcher,
|
||||
MiddlewareProvider $middlewareProvider,
|
||||
Log $log,
|
||||
Config $config,
|
||||
SystemConfig $systemConfig,
|
||||
ApplicationState $applicationState
|
||||
) {
|
||||
$routeCacheFile = 'data/cache/application/slim-routes-portal-' . $applicationState->getPortalId() . '.php';
|
||||
@@ -57,7 +57,7 @@ class Starter extends StarterBase
|
||||
$routeParamsFetcher,
|
||||
$middlewareProvider,
|
||||
$log,
|
||||
$config,
|
||||
$systemConfig,
|
||||
$routeCacheFile
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ class CountryDataProvider
|
||||
|
||||
public function __construct(
|
||||
private DataCache $dataCache,
|
||||
private Config $config,
|
||||
private EntityManager $entityManager
|
||||
private EntityManager $entityManager,
|
||||
Config\SystemConfig $systemConfig,
|
||||
) {
|
||||
$this->useCache = (bool) $this->config->get('useCache');
|
||||
$this->useCache = $systemConfig->useCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Utils\Autoload\Loader;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Resource\PathProvider;
|
||||
|
||||
@@ -44,12 +45,12 @@ class Autoload
|
||||
private string $autoloadFileName = 'autoload.json';
|
||||
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Metadata $metadata,
|
||||
private DataCache $dataCache,
|
||||
private FileManager $fileManager,
|
||||
private Loader $loader,
|
||||
private PathProvider $pathProvider
|
||||
private PathProvider $pathProvider,
|
||||
private SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ class Autoload
|
||||
|
||||
private function init(): void
|
||||
{
|
||||
$useCache = $this->config->get('useCache');
|
||||
$useCache = $this->systemConfig->useCache();
|
||||
|
||||
if ($useCache && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var ?array<string, mixed> $data */
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Utils\Autoload;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Log;
|
||||
@@ -68,10 +68,10 @@ class NamespaceLoader
|
||||
private ClassLoader $classLoader;
|
||||
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private DataCache $dataCache,
|
||||
private FileManager $fileManager,
|
||||
private Log $log
|
||||
private Log $log,
|
||||
private SystemConfig $systemConfig,
|
||||
) {
|
||||
|
||||
$this->classLoader = new ClassLoader();
|
||||
@@ -231,7 +231,7 @@ class NamespaceLoader
|
||||
*/
|
||||
private function getVendorNamespaces(string $path): array
|
||||
{
|
||||
$useCache = $this->config->get('useCache');
|
||||
$useCache = $this->systemConfig->useCache();
|
||||
|
||||
if (!isset($this->vendorNamespaces)) {
|
||||
$this->vendorNamespaces = [];
|
||||
|
||||
@@ -36,6 +36,8 @@ use Espo\Core\Utils\Client\LoaderParamsProvider;
|
||||
use Espo\Core\Utils\Client\RenderParams;
|
||||
use Espo\Core\Utils\Client\Script;
|
||||
use Espo\Core\Utils\Client\SecurityParams;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
use Slim\Psr7\Response as Psr7Response;
|
||||
@@ -66,6 +68,8 @@ class ClientManager
|
||||
private DevModeJsFileListProvider $devModeJsFileListProvider,
|
||||
private Module $module,
|
||||
private LoaderParamsProvider $loaderParamsProvider,
|
||||
private SystemConfig $systemConfig,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {
|
||||
$this->nonce = Util::generateKey();
|
||||
}
|
||||
@@ -130,7 +134,7 @@ class ClientManager
|
||||
return;
|
||||
}
|
||||
|
||||
$siteUrl = $this->config->get('siteUrl') ?? '';
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
if (str_starts_with($siteUrl, 'https://')) {
|
||||
$response->setHeader('Strict-Transport-Security', 'max-age=10368000');
|
||||
@@ -308,7 +312,7 @@ class ClientManager
|
||||
|
||||
private function useCache(): bool
|
||||
{
|
||||
return (bool) $this->config->get('useCache');
|
||||
return $this->systemConfig->useCache();
|
||||
}
|
||||
|
||||
private function useCacheInDeveloperMode(): bool
|
||||
|
||||
@@ -42,7 +42,7 @@ class ApplicationConfig
|
||||
|
||||
public function getSiteUrl(): string
|
||||
{
|
||||
return rtrim($this->config->get('siteUrl'), '/');
|
||||
return rtrim($this->config->get('siteUrl') ?? '', '/');
|
||||
}
|
||||
|
||||
public function getDateFormat(): string
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* 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\Core\Utils\Config;
|
||||
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
/**
|
||||
* @since 9.1.0
|
||||
*/
|
||||
class SystemConfig
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
) {}
|
||||
|
||||
public function useCache(): bool
|
||||
{
|
||||
return (bool) $this->config->get('useCache');
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Mail\FiltersMatcher;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\EmailFilter;
|
||||
use Espo\Entities\User;
|
||||
@@ -54,9 +55,9 @@ class EmailFilterManager
|
||||
private EntityManager $entityManager,
|
||||
private FiltersMatcher $filtersMatcher,
|
||||
private DataCache $dataCache,
|
||||
Config $config
|
||||
SystemConfig $systemConfig,
|
||||
) {
|
||||
$this->useCache = (bool) $config->get('useCache');
|
||||
$this->useCache = $systemConfig->useCache();
|
||||
}
|
||||
|
||||
public function getMatchingFilter(Email $email, string $userId): ?EmailFilter
|
||||
|
||||
@@ -42,10 +42,10 @@ class ClassMap
|
||||
{
|
||||
public function __construct(
|
||||
private FileManager $fileManager,
|
||||
private Config $config,
|
||||
private Module $module,
|
||||
private DataCache $dataCache,
|
||||
private PathProvider $pathProvider
|
||||
private PathProvider $pathProvider,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ class ClassMap
|
||||
if (
|
||||
$cacheKey &&
|
||||
$this->dataCache->has($cacheKey) &&
|
||||
$this->config->get('useCache')
|
||||
$this->systemConfig->useCache()
|
||||
) {
|
||||
/** @var array<string,class-string> $data */
|
||||
$data = $this->dataCache->get($cacheKey);
|
||||
@@ -102,7 +102,7 @@ class ClassMap
|
||||
)
|
||||
);
|
||||
|
||||
if ($cacheKey && $this->config->get('useCache')) {
|
||||
if ($cacheKey && $this->systemConfig->useCache()) {
|
||||
$this->dataCache->store($cacheKey, $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ class LanguageFactory
|
||||
{
|
||||
public function __construct(
|
||||
private InjectableFactory $injectableFactory,
|
||||
private Config $config,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
public function create(string $language): Language
|
||||
{
|
||||
return $this->injectableFactory->createWith(Language::class, [
|
||||
'language' => $language,
|
||||
'useCache' => $this->config->get('useCache') ?? false,
|
||||
'useCache' => $this->systemConfig->useCache(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,10 @@ class OrmMetadataData
|
||||
|
||||
public function __construct(
|
||||
private DataCache $dataCache,
|
||||
private Config $config,
|
||||
private InjectableFactory $injectableFactory
|
||||
private InjectableFactory $injectableFactory,
|
||||
Config\SystemConfig $systemConfig,
|
||||
) {
|
||||
|
||||
$this->useCache = (bool) $this->config->get('useCache', false);
|
||||
$this->useCache = $systemConfig->useCache();
|
||||
}
|
||||
|
||||
private function getConverter(): Converter
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Api\Action;
|
||||
use Espo\Core\Api\Route as RouteItem;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Resource\PathProvider;
|
||||
|
||||
@@ -52,11 +53,11 @@ class Route
|
||||
private string $routesFileName = 'routes.json';
|
||||
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Metadata $metadata,
|
||||
private FileManager $fileManager,
|
||||
private DataCache $dataCache,
|
||||
private PathProvider $pathProvider
|
||||
private PathProvider $pathProvider,
|
||||
private SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -89,7 +90,7 @@ class Route
|
||||
|
||||
private function init(): void
|
||||
{
|
||||
$useCache = $this->config->get('useCache');
|
||||
$useCache = $this->systemConfig->useCache();
|
||||
|
||||
if ($this->dataCache->has($this->cacheKey) && $useCache) {
|
||||
/** @var ?(RouteArrayShape[]) $data */
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Core\Utils\Log;
|
||||
@@ -65,7 +66,8 @@ class Manager
|
||||
private DataCache $dataCache,
|
||||
private EntityManager $entityManager,
|
||||
private FieldUtil $fieldUtil,
|
||||
private Log $log
|
||||
private Log $log,
|
||||
private SystemConfig $systemConfig,
|
||||
) {
|
||||
|
||||
$this->loadData();
|
||||
@@ -73,7 +75,7 @@ class Manager
|
||||
|
||||
private function loadData(): void
|
||||
{
|
||||
if ($this->config->get('useCache') && $this->dataCache->has($this->cacheKey)) {
|
||||
if ($this->systemConfig->useCache() && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var array<string, bool> $data */
|
||||
$data = $this->dataCache->get($this->cacheKey);
|
||||
|
||||
@@ -83,7 +85,7 @@ class Manager
|
||||
if (is_null($this->data)) {
|
||||
$this->data = $this->buildData();
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($this->systemConfig->useCache()) {
|
||||
$this->storeDataToCache();
|
||||
}
|
||||
}
|
||||
@@ -132,7 +134,7 @@ class Manager
|
||||
{
|
||||
$this->data[$event] = true;
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($this->systemConfig->useCache()) {
|
||||
$this->storeDataToCache();
|
||||
}
|
||||
}
|
||||
@@ -154,7 +156,7 @@ class Manager
|
||||
if ($notExists) {
|
||||
unset($this->data[$event]);
|
||||
|
||||
if ($this->config->get('useCache')) {
|
||||
if ($this->systemConfig->useCache()) {
|
||||
$this->storeDataToCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ class Manager
|
||||
private EntityManager $entityManager,
|
||||
private Config $config,
|
||||
private Language $language,
|
||||
private ScheduledJob $scheduledJob
|
||||
private ScheduledJob $scheduledJob,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ class Manager
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!$this->config->get('useCache')) {
|
||||
if (!$this->systemConfig->useCache()) {
|
||||
$notificationList[] = [
|
||||
'id' => 'cacheIsDisabled',
|
||||
'type' => 'cacheIsDisabled',
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Tools\App\Language;
|
||||
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\SystemConfig;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\ORM\Defs;
|
||||
@@ -54,10 +55,10 @@ class AclDependencyProvider
|
||||
public function __construct(
|
||||
private DataCache $dataCache,
|
||||
private Metadata $metadata,
|
||||
Config $config,
|
||||
private Defs $ormDefs
|
||||
private Defs $ormDefs,
|
||||
SystemConfig $systemConfig,
|
||||
) {
|
||||
$this->useCache = $config->get('useCache');
|
||||
$this->useCache = $systemConfig->useCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,10 +54,10 @@ class AclDependencyProvider
|
||||
public function __construct(
|
||||
private DataCache $dataCache,
|
||||
private Metadata $metadata,
|
||||
Config $config,
|
||||
private Defs $ormDefs
|
||||
private Defs $ormDefs,
|
||||
Config\SystemConfig $systemConfig,
|
||||
) {
|
||||
$this->useCache = $config->get('useCache');
|
||||
$this->useCache = $systemConfig->useCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,8 @@ class SettingsService
|
||||
private InjectableFactory $injectableFactory,
|
||||
private Access $access,
|
||||
private AuthenticationMethodProvider $authenticationMethodProvider,
|
||||
private ThemeManager $themeManager
|
||||
private ThemeManager $themeManager,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -222,7 +223,7 @@ class SettingsService
|
||||
|
||||
if (
|
||||
isset($data->useCache) &&
|
||||
$data->useCache !== $this->config->get('useCache')
|
||||
$data->useCache !== $this->systemConfig->useCache()
|
||||
) {
|
||||
$this->dataManager->clearCache();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ class FormService
|
||||
private Language\LanguageFactory $languageFactory,
|
||||
private DataCache $dataCache,
|
||||
private ThemeManager $themeManager,
|
||||
private Config\SystemConfig $systemConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -86,7 +87,7 @@ class FormService
|
||||
{
|
||||
$cacheKey = $this->getCacheKey($leadCapture);
|
||||
|
||||
if ($this->config->get('useCache') && $this->dataCache->has($cacheKey)) {
|
||||
if ($this->systemConfig->useCache() && $this->dataCache->has($cacheKey)) {
|
||||
return $this->getFromCache($cacheKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Acl\Map;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
use Espo\Core\Acl\FieldData;
|
||||
use Espo\Core\Acl\Map\CacheKeyProvider;
|
||||
use Espo\Core\Acl\Map\DataBuilder;
|
||||
@@ -42,31 +40,30 @@ use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\FieldUtil;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
|
||||
class MapTest extends \PHPUnit\Framework\TestCase
|
||||
class MapTest extends TestCase
|
||||
{
|
||||
private $fieldUtil;
|
||||
private $config;
|
||||
private $systemConfig;
|
||||
private $table;
|
||||
private $metadataProvider;
|
||||
private $cacheKeyProvider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->systemConfig = $this->createMock(Config\SystemConfig::class);
|
||||
$this->fieldUtil = $this->createMock(FieldUtil::class);
|
||||
$this->table = $this->createMock(Table::class);
|
||||
$this->dataCache = $this->createMock(DataCache::class);
|
||||
$this->metadataProvider = $this->createMock(MetadataProvider::class);
|
||||
$this->cacheKeyProvider = $this->createMock(CacheKeyProvider::class);
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->willReturnMap([
|
||||
['useCache', false]
|
||||
]);
|
||||
->method('useCache')
|
||||
->willReturn(false);
|
||||
}
|
||||
|
||||
private function mockTableData(array $scopeData, array $fieldData, array $permissionData): void
|
||||
@@ -206,9 +203,9 @@ class MapTest extends \PHPUnit\Framework\TestCase
|
||||
$map = new Map(
|
||||
$this->table,
|
||||
$dataBuilder,
|
||||
$this->config,
|
||||
$this->dataCache,
|
||||
$this->cacheKeyProvider
|
||||
$this->cacheKeyProvider,
|
||||
$this->systemConfig,
|
||||
);
|
||||
|
||||
$this->assertEquals($expectedData, $map->getData());
|
||||
|
||||
@@ -29,31 +29,33 @@
|
||||
|
||||
namespace tests\unit\Espo\Core;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use tests\unit\ReflectionHelper;
|
||||
|
||||
use Espo\Core\{
|
||||
Hook\GeneralInvoker,
|
||||
HookManager,
|
||||
InjectableFactory,
|
||||
Utils\Metadata,
|
||||
Utils\Config,
|
||||
Utils\File\Manager as FileManager,
|
||||
Utils\DataCache,
|
||||
Utils\Log,
|
||||
Utils\Module\PathProvider};
|
||||
use Espo\Core\Hook\GeneralInvoker;
|
||||
use Espo\Core\HookManager;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Log;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Module\PathProvider;
|
||||
|
||||
class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
class HookManagerTest extends TestCase
|
||||
{
|
||||
private $hookManager;
|
||||
|
||||
private $filesPath = 'tests/unit/testData/Hooks';
|
||||
|
||||
private ?Config\SystemConfig $systemConfig = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
$this->getMockBuilder(Metadata::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->systemConfig = $this->createMock(Config\SystemConfig::class);
|
||||
|
||||
$this->injectableFactory = $this->createMock(InjectableFactory::class);
|
||||
$this->dataCache = $this->createMock(DataCache::class);
|
||||
@@ -65,11 +67,11 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
$this->injectableFactory,
|
||||
$this->fileManager,
|
||||
$this->metadata,
|
||||
$this->config,
|
||||
$this->dataCache,
|
||||
$this->createMock(Log::class),
|
||||
$this->pathProvider,
|
||||
$this->generalInvoker
|
||||
$this->generalInvoker,
|
||||
$this->systemConfig,
|
||||
);
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->hookManager);
|
||||
@@ -255,9 +257,9 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->initPathProvider('testCase1');
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->metadata
|
||||
@@ -290,9 +292,9 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->initPathProvider('testCase2');
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->metadata
|
||||
@@ -326,9 +328,9 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->initPathProvider('testCase2');
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->metadata
|
||||
@@ -362,9 +364,9 @@ class HookManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->initPathProvider('testCase3');
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->metadata
|
||||
|
||||
@@ -29,21 +29,22 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Autoload,
|
||||
Utils\Config,
|
||||
Utils\Metadata,
|
||||
Utils\Autoload\Loader,
|
||||
Utils\DataCache,
|
||||
Utils\File\Manager as FileManager,
|
||||
Utils\Resource\PathProvider,
|
||||
};
|
||||
use Espo\Core\Utils\Autoload;
|
||||
use Espo\Core\Utils\Autoload\Loader;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Resource\PathProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AutoloadTest extends \PHPUnit\Framework\TestCase
|
||||
class AutoloadTest extends TestCase
|
||||
{
|
||||
private ?Config\SystemConfig $systemConfig = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->systemConfig = $this->createMock(Config\SystemConfig::class);
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
$this->dataCache = $this->createMock(DataCache::class);
|
||||
$this->fileManager = $this->createMock(FileManager::class);
|
||||
@@ -53,12 +54,12 @@ class AutoloadTest extends \PHPUnit\Framework\TestCase
|
||||
$this->initPathProvider();
|
||||
|
||||
$this->autoload = new Autoload(
|
||||
$this->config,
|
||||
$this->metadata,
|
||||
$this->dataCache,
|
||||
$this->fileManager,
|
||||
$this->loader,
|
||||
$this->pathProvider
|
||||
$this->pathProvider,
|
||||
$this->systemConfig,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,10 +95,9 @@ class AutoloadTest extends \PHPUnit\Framework\TestCase
|
||||
->method('getModuleList')
|
||||
->willReturn(['M1', 'M2']);
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->with('useCache')
|
||||
->method('useCache')
|
||||
->willReturn(false);
|
||||
|
||||
$this->fileManager
|
||||
|
||||
@@ -29,18 +29,16 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Utils\File;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use tests\unit\ReflectionHelper;
|
||||
|
||||
use Espo\Core\Utils\File\ClassMap;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Module;
|
||||
|
||||
use Espo\Core\Utils\Module\PathProvider;
|
||||
|
||||
class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
class ClassMapTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ClassMap
|
||||
@@ -50,9 +48,7 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
protected $reflection;
|
||||
|
||||
private $customPath = 'tests/unit/testData/EntryPoints/Espo/Custom/';
|
||||
|
||||
private $corePath = 'tests/unit/testData/EntryPoints/Espo/';
|
||||
|
||||
private $modulePath = 'tests/unit/testData/EntryPoints/Espo/Modules/{*}/';
|
||||
|
||||
/**
|
||||
@@ -64,7 +60,7 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->fileManager = new FileManager();
|
||||
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->systemConfig = $this->createMock(Config\SystemConfig::class);
|
||||
$this->module = $this->createMock(Module::class);
|
||||
|
||||
$this->dataCache = $this->createMock(DataCache::class);
|
||||
@@ -97,10 +93,10 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->classMap = new ClassMap(
|
||||
$this->fileManager,
|
||||
$this->config,
|
||||
$this->module,
|
||||
$this->dataCache,
|
||||
$pathProvider
|
||||
$pathProvider,
|
||||
$this->systemConfig,
|
||||
);
|
||||
|
||||
$this->reflection = new ReflectionHelper($this->classMap);
|
||||
@@ -125,9 +121,9 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
->with('entryPoints')
|
||||
->willReturn(true);
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(false));
|
||||
|
||||
$this->module
|
||||
@@ -157,9 +153,9 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
'Download' => 'tests\\unit\\testData\\EntryPoints\\Espo\\EntryPoints\\Download',
|
||||
];
|
||||
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$cacheKey = 'entryPoints';
|
||||
@@ -185,10 +181,9 @@ class ClassMapTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testGetDataWithNoCacheString(): void
|
||||
{
|
||||
$this->config
|
||||
$this->systemConfig
|
||||
->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('useCache')
|
||||
->method('useCache')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$this->module
|
||||
|
||||
@@ -45,7 +45,6 @@ class RouteTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->fileManager = new FileManager();
|
||||
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
@@ -53,11 +52,11 @@ class RouteTest extends TestCase
|
||||
$this->pathProvider = $this->createMock(PathProvider::class);
|
||||
|
||||
$this->route = new Route(
|
||||
$this->config,
|
||||
$this->metadata,
|
||||
$this->fileManager,
|
||||
$this->dataCache,
|
||||
$this->pathProvider
|
||||
$this->pathProvider,
|
||||
$this->createMock(Config\SystemConfig::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user