Skip to content

EspoCRM – Open Source CRM Application

System data cache service

Yuriifa9d05439e0f
diff --git a/application/Espo/Binding.php b/application/Espo/Binding.php
index 69417feb1a..83cc5562a5 100644
--- a/application/Espo/Binding.php
+++ b/application/Espo/Binding.php
@@ -30,9 +30,17 @@
namespace Espo;
use Espo\Core\Binding\Binder;
+use Espo\Core\Binding\BindingContainerBuilder;
use Espo\Core\Binding\BindingProcessor;
use Espo\Core\Binding\Key\NamedClassKey;
use Espo\Core\Binding\Key\QualifiedClassKey;
+use Espo\Core\Container;
+use Espo\Core\InjectableFactory;
+use Espo\Core\Utils\Cache\DataCacheAccess;
+use Espo\Core\Utils\Cache\DataCacheServiceName as DataCacheServiceName;
+use Espo\Core\Utils\Cache\FileCacheItemPool;
+use Espo\Core\Utils\DataCache;
+use Psr\Cache\CacheItemPoolInterface;
/**
* Default binding for the dependency injection framework. Custom binding should be set up in
@@ -89,6 +97,8 @@ class Binding implements BindingProcessor
'fileManager'
);
+ $this->bindDataCacheServices($binder);
+
$binder->bindService(
'Espo\\ORM\\EntityManager',
'entityManager'
@@ -332,6 +342,11 @@ class Binding implements BindingProcessor
'Espo\\Core\\Job\\Processing\\RabbitMq\\Consumer',
);
});
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
}
private function bindMisc(Binder $binder): void
@@ -451,4 +466,32 @@ class Binding implements BindingProcessor
'Espo\\Core\\Mail\\Account\\GroupAccount\\StorageFactory'
);
}
+
+ private function bindDataCacheServices(Binder $binder): void
+ {
+ $binder->bindService(
+ DataCache::class,
+ DataCacheServiceName::APPLICATION
+ );
+
+ $binder->bindService(
+ QualifiedClassKey::create(DataCache::class, DataCache::QUALIFIER_SYSTEM),
+ DataCacheServiceName::SYSTEM
+ );
+
+ $binder->bindCallback(
+ QualifiedClassKey::create(DataCacheAccess::class, DataCache::QUALIFIER_SYSTEM),
+ function (InjectableFactory $injectableFactory, Container $container) {
+ return $injectableFactory->createWithBinding(
+ DataCacheAccess::class,
+ BindingContainerBuilder::create()
+ ->bindInstance(
+ DataCache::class,
+ $container->get(DataCacheServiceName::SYSTEM)
+ )
+ ->build()
+ );
+ }
+ );
+ }
}
diff --git a/application/Espo/Classes/AppInfo/Container.php b/application/Espo/Classes/AppInfo/Container.php
index 96b6539495..6424b7f529 100644
--- a/application/Espo/Classes/AppInfo/Container.php
+++ b/application/Espo/Classes/AppInfo/Container.php
@@ -53,6 +53,7 @@ class Container implements InfoProvider
'dataManager',
'metadata',
'user',
+ 'systemDataCache',
];
/** @var string[] $fileList */
diff --git a/application/Espo/Core/Container/ContainerBuilder.php b/application/Espo/Core/Container/ContainerBuilder.php
index b612760811..4be533ec51 100644
--- a/application/Espo/Core/Container/ContainerBuilder.php
+++ b/application/Espo/Core/Container/ContainerBuilder.php
@@ -39,6 +39,7 @@ use Espo\Core\Binding\EspoBindingLoader;
use Espo\Core\Loaders\ApplicationState as ApplicationStateLoader;
use Espo\Core\Utils\Cache\FileCacheItemPool;
+use Espo\Core\Utils\Cache\DataCacheServiceName;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Config\ConfigFileManager;
use Espo\Core\Utils\Config;
@@ -177,7 +178,7 @@ class ContainerBuilder
$cacheItemPool = new FileCacheItemPool($fileManager);
/** @var DataCache $dataCache */
- $dataCache = $this->services['dataCache'] ?? (
+ $dataCache = $this->services[DataCacheServiceName::SYSTEM] ?? (
new DataCache($cacheItemPool)
);
@@ -192,7 +193,7 @@ class ContainerBuilder
$this->services['config'] = $config;
$this->services['fileManager'] = $fileManager;
- $this->services['dataCache'] = $dataCache;
+ $this->services[DataCacheServiceName::SYSTEM] = $dataCache;
$this->services['module'] = $module;
$this->services['systemConfig'] = $systemConfig;
diff --git a/application/Espo/Core/Di/DataCacheSetter.php b/application/Espo/Core/Di/DataCacheSetter.php
index 4c7c970741..857b02565c 100644
--- a/application/Espo/Core/Di/DataCacheSetter.php
+++ b/application/Espo/Core/Di/DataCacheSetter.php
@@ -31,6 +31,9 @@ namespace Espo\Core\Di;
use Espo\Core\Utils\DataCache;
+/**
+ * @phpstan-ignore-next-line trait.unused
+ */
trait DataCacheSetter
{
/**
diff --git a/application/Espo/Core/Hook/DataProvider.php b/application/Espo/Core/Hook/DataProvider.php
index 2a064956f4..db9f0e81ea 100644
--- a/application/Espo/Core/Hook/DataProvider.php
+++ b/application/Espo/Core/Hook/DataProvider.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Hook;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -63,6 +64,7 @@ class DataProvider
private SystemConfig $systemConfig,
private FileManager $fileManager,
private PathProvider $pathProvider,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private Metadata $metadata,
) {}
diff --git a/application/Espo/Core/Utils/Autoload.php b/application/Espo/Core/Utils/Autoload.php
index 59f5b033ce..ceccb65cd0 100644
--- a/application/Espo/Core/Utils/Autoload.php
+++ b/application/Espo/Core/Utils/Autoload.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Autoload\Loader;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -46,6 +47,7 @@ class Autoload
public function __construct(
private Metadata $metadata,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private FileManager $fileManager,
private Loader $loader,
diff --git a/application/Espo/Core/Utils/Autoload/NamespaceLoader.php b/application/Espo/Core/Utils/Autoload/NamespaceLoader.php
index e5794e26f0..cc94fd1f89 100644
--- a/application/Espo/Core/Utils/Autoload/NamespaceLoader.php
+++ b/application/Espo/Core/Utils/Autoload/NamespaceLoader.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils\Autoload;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -68,6 +69,7 @@ class NamespaceLoader
private ClassLoader $classLoader;
public function __construct(
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private FileManager $fileManager,
private Log $log,
diff --git a/application/Espo/Core/Utils/Cache/DataCacheServiceLoader.php b/application/Espo/Core/Utils/Cache/DataCacheServiceLoader.php
new file mode 100644
index 0000000000..35d7106253
--- /dev/null
+++ b/application/Espo/Core/Utils/Cache/DataCacheServiceLoader.php
@@ -0,0 +1,56 @@
+<?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\Core\Utils\Cache;
+
+use Espo\Core\Container;
+use Espo\Core\Container\Loader;
+use Espo\Core\Utils\DataCache;
+use RuntimeException;
+
+/**
+ * @noinspection PhpUnused
+ */
+class DataCacheServiceLoader implements Loader
+{
+ public function __construct(
+ private Container $container,
+ ) {}
+
+ public function load(): DataCache
+ {
+ $service = $this->container->get(DataCacheServiceName::SYSTEM);
+
+ if (!$service instanceof DataCache) {
+ throw new RuntimeException("Unexpected 'dataCache' service instance.");
+ }
+
+ return $service;
+ }
+}
diff --git a/application/Espo/Core/Utils/Cache/DataCacheServiceName.php b/application/Espo/Core/Utils/Cache/DataCacheServiceName.php
new file mode 100644
index 0000000000..219c3942be
--- /dev/null
+++ b/application/Espo/Core/Utils/Cache/DataCacheServiceName.php
@@ -0,0 +1,39 @@
+<?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\Core\Utils\Cache;
+
+/**
+ * @since 10.1.0
+ */
+class DataCacheServiceName
+{
+ public const string SYSTEM = 'systemDataCache';
+ public const string APPLICATION = 'dataCache';
+}
diff --git a/application/Espo/Core/Utils/DataCache.php b/application/Espo/Core/Utils/DataCache.php
index 2fcdae5096..7cd309ec62 100644
--- a/application/Espo/Core/Utils/DataCache.php
+++ b/application/Espo/Core/Utils/DataCache.php
@@ -33,14 +33,21 @@ use Espo\Core\Utils\Cache\CacheItem;
use Espo\Core\Utils\Cache\Exceptions\InvalidArgument;
use Espo\Core\Utils\Cache\Exceptions\PersistenceError;
use Espo\Core\Utils\Cache\Exceptions\ReadError;
-use Espo\Core\Utils\Cache\FileCacheItemPool;
-use InvalidArgumentException;
+use Psr\Cache\CacheItemPoolInterface;
+use Psr\Cache\InvalidArgumentException;
use stdClass;
class DataCache
{
+ /**
+ * DI qualifier. Can be applied to the DataCache and DataCacheAccess dependencies.
+ *
+ * @since 10.1.0
+ */
+ public const string QUALIFIER_SYSTEM = 'system';
+
public function __construct(
- private FileCacheItemPool $fileCacheItemPool,
+ private CacheItemPoolInterface $pool,
) {}
/**
@@ -48,7 +55,11 @@ class DataCache
*/
public function has(string $key): bool
{
- return $this->fileCacheItemPool->hasItem($key);
+ try {
+ return $this->pool->hasItem($key);
+ } catch (InvalidArgumentException $e) {
+ throw new InvalidArgument(previous: $e);
+ }
}
/**
@@ -59,7 +70,11 @@ class DataCache
*/
public function get(string $key): array|stdClass|null
{
- $item = $this->fileCacheItemPool->getItem($key);
+ try {
+ $item = $this->pool->getItem($key);
+ } catch (InvalidArgumentException $e) {
+ throw new InvalidArgument(previous: $e);
+ }
if (!$item->isHit()) {
return null;
@@ -105,7 +120,7 @@ class DataCache
/** @phpstan-var mixed $data */
if (!$this->checkDataIsValid($data)) {
- throw new InvalidArgumentException("Bad cache data type.");
+ throw new InvalidArgument("Bad cache data type.");
}
$item = new CacheItem(
@@ -113,7 +128,7 @@ class DataCache
value: $data,
);
- $result = $this->fileCacheItemPool->save($item);
+ $result = $this->pool->save($item);
if ($result === false) {
throw new PersistenceError("Could not store '$key'.");
@@ -127,18 +142,12 @@ class DataCache
*/
public function clear(string $key): void
{
- $this->fileCacheItemPool->deleteItem($key);
+ $this->pool->deleteItem($key);
}
- /**
- * @param mixed $data
- * @return bool
- */
- private function checkDataIsValid($data)
+ private function checkDataIsValid(mixed $data): bool
{
- $isInvalid =
- !is_array($data) &&
- !$data instanceof stdClass;
+ $isInvalid = !is_array($data) && !$data instanceof stdClass;
return !$isInvalid;
}
diff --git a/application/Espo/Core/Utils/File/ClassMap.php b/application/Espo/Core/Utils/File/ClassMap.php
index 5545b313dd..687cdea2e9 100644
--- a/application/Espo/Core/Utils/File/ClassMap.php
+++ b/application/Espo/Core/Utils/File/ClassMap.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils\File;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -43,6 +44,7 @@ class ClassMap
public function __construct(
private FileManager $fileManager,
private Module $module,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private PathProvider $pathProvider,
private Config\SystemConfig $systemConfig,
diff --git a/application/Espo/Core/Utils/Language.php b/application/Espo/Core/Utils/Language.php
index 06154bf07a..fe215bfa55 100644
--- a/application/Espo/Core/Utils/Language.php
+++ b/application/Espo/Core/Utils/Language.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Resource\Reader as ResourceReader;
use Espo\Core\Utils\Resource\Reader\Params as ResourceReaderParams;
@@ -80,6 +81,7 @@ class Language
?string $language,
private FileManager $fileManager,
private ResourceReader $resourceReader,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
protected bool $useCache = false,
protected bool $noCustom = false,
diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php
index 96191c963f..76c6365745 100644
--- a/application/Espo/Core/Utils/Metadata.php
+++ b/application/Espo/Core/Utils/Metadata.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Utils\Cache\DataCacheAccess;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Metadata\Builder;
@@ -61,7 +62,9 @@ class Metadata
private Module $module,
private Builder $builder,
private BuilderHelper $builderHelper,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCacheAccess $data,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCacheAccess $objectData,
) {
diff --git a/application/Espo/Core/Utils/Metadata/OrmMetadataData.php b/application/Espo/Core/Utils/Metadata/OrmMetadataData.php
index 64b2a7ce5e..ada514fc08 100644
--- a/application/Espo/Core/Utils/Metadata/OrmMetadataData.php
+++ b/application/Espo/Core/Utils/Metadata/OrmMetadataData.php
@@ -29,6 +29,7 @@
namespace Espo\Core\Utils\Metadata;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\InjectableFactory;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\Database\Orm\Converter;
@@ -44,6 +45,7 @@ class OrmMetadataData
private ?Converter $converter = null;
public function __construct(
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private InjectableFactory $injectableFactory,
Config\SystemConfig $systemConfig,
diff --git a/application/Espo/Core/Utils/Route.php b/application/Espo/Core/Utils/Route.php
index 9cf4c0bb34..9d0d0a6262 100644
--- a/application/Espo/Core/Utils/Route.php
+++ b/application/Espo/Core/Utils/Route.php
@@ -31,6 +31,7 @@ namespace Espo\Core\Utils;
use Espo\Core\Api\Action;
use Espo\Core\Api\Route as RouteItem;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -56,6 +57,7 @@ class Route
public function __construct(
private Metadata $metadata,
private FileManager $fileManager,
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private PathProvider $pathProvider,
private SystemConfig $systemConfig,
diff --git a/application/Espo/Resources/metadata/app/containerServices.json b/application/Espo/Resources/metadata/app/containerServices.json
index 1aac94eea0..592ac7ecd1 100644
--- a/application/Espo/Resources/metadata/app/containerServices.json
+++ b/application/Espo/Resources/metadata/app/containerServices.json
@@ -2,6 +2,9 @@
"authTokenManager": {
"className": "Espo\\Core\\Authentication\\AuthToken\\EspoManager"
},
+ "dataCache": {
+ "loaderClassName": "Espo\\Core\\Utils\\Cache\\DataCacheServiceLoader"
+ },
"ormMetadataData": {
"className": "Espo\\Core\\Utils\\Metadata\\OrmMetadataData"
},
diff --git a/application/Espo/Tools/App/Language/AclDependencyProvider.php b/application/Espo/Tools/App/Language/AclDependencyProvider.php
index 96fd6d2e27..09acdc5f94 100644
--- a/application/Espo/Tools/App/Language/AclDependencyProvider.php
+++ b/application/Espo/Tools/App/Language/AclDependencyProvider.php
@@ -29,6 +29,7 @@
namespace Espo\Tools\App\Language;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\ORM\Type\FieldType;
use Espo\Core\Utils\Config\SystemConfig;
use Espo\Core\Utils\DataCache;
@@ -52,6 +53,7 @@ class AclDependencyProvider
private bool $useCache;
public function __construct(
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private Metadata $metadata,
private Defs $ormDefs,
diff --git a/application/Espo/Tools/App/Metadata/AclDependencyProvider.php b/application/Espo/Tools/App/Metadata/AclDependencyProvider.php
index e9ba71cc3c..635c213c05 100644
--- a/application/Espo/Tools/App/Metadata/AclDependencyProvider.php
+++ b/application/Espo/Tools/App/Metadata/AclDependencyProvider.php
@@ -29,6 +29,7 @@
namespace Espo\Tools\App\Metadata;
+use Espo\Core\Binding\Attributes\Qualify;
use Espo\Core\ORM\Type\FieldType;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\DataCache;
@@ -52,6 +53,7 @@ class AclDependencyProvider
private bool $useCache;
public function __construct(
+ #[Qualify(DataCache::QUALIFIER_SYSTEM)]
private DataCache $dataCache,
private Metadata $metadata,
private Defs $ormDefs,
diff --git a/application/Espo/Tools/LabelManager/LabelManager.php b/application/Espo/Tools/LabelManager/LabelManager.php
index 0535c6cfc2..8e8992d3c0 100644
--- a/application/Espo/Tools/LabelManager/LabelManager.php
+++ b/application/Espo/Tools/LabelManager/LabelManager.php
@@ -42,13 +42,11 @@ use stdClass;
class LabelManager implements
Di\DefaultLanguageAware,
Di\MetadataAware,
- Di\FileManagerAware,
- Di\DataCacheAware
+ Di\FileManagerAware
{
use Di\DefaultLanguageSetter;
use Di\MetadataSetter;
use Di\FileManagerSetter;
- use Di\DataCacheSetter;
/** @var string[] */
protected $ignoreList = [
diff --git a/tests/integration/Core/BaseTestCase.php b/tests/integration/Core/BaseTestCase.php
index c1b971bea5..d861abb986 100644
--- a/tests/integration/Core/BaseTestCase.php
+++ b/tests/integration/Core/BaseTestCase.php
@@ -37,6 +37,7 @@ use Espo\Core\Container;
use Espo\Core\DataManager;
use Espo\Core\Exceptions\Error;
use Espo\Core\InjectableFactory;
+use Espo\Core\Utils\Cache\DataCacheServiceName as CacheServiceName;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\Utils\Metadata;
@@ -249,6 +250,7 @@ abstract class BaseTestCase extends TestCase
'module',
'fileManager',
'applicationParams',
+ CacheServiceName::SYSTEM,
]);
if ($username === null && $method === null) {
diff --git a/tests/integration/Espo/Core/Binding/BindingTest.php b/tests/integration/Espo/Core/Binding/BindingTest.php
index 5bb2d80404..820e4fc4d8 100644
--- a/tests/integration/Espo/Core/Binding/BindingTest.php
+++ b/tests/integration/Espo/Core/Binding/BindingTest.php
@@ -37,6 +37,8 @@ use Espo\Core\Binding\BindingLoader;
use Espo\Core\Binding\Key\QualifiedClassKey;
use Espo\Core\Container\ContainerBuilder;
use Espo\Core\InjectableFactory;
+use Espo\Core\Utils\Cache\FileCacheItemPool;
+use Psr\Cache\CacheItemPoolInterface;
use tests\integration\Core\BaseTestCase;
use tests\integration\testClasses\Binding\SomeClass;
use tests\integration\testClasses\Binding\SomeClassRequiringService;
@@ -57,6 +59,13 @@ class BindingTest extends BaseTestCase
{
$data = new BindingData();
+ $binder = new Binder($data);
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$data->addGlobal(
SomeInterface::class,
Binding::createFromImplementationClassName(
@@ -95,6 +104,13 @@ class BindingTest extends BaseTestCase
{
$data = new BindingData();
+ $binder = new Binder($data);
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$data->addGlobal(
SomeInterface::class,
Binding::createFromFactoryClassName(
@@ -133,6 +149,13 @@ class BindingTest extends BaseTestCase
{
$data = new BindingData();
+ $binder = new Binder($data);
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$data->addGlobal(
SomeInterface::class,
Binding::createFromCallback(
@@ -173,6 +196,13 @@ class BindingTest extends BaseTestCase
{
$data = new BindingData();
+ $binder = new Binder($data);
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$data->addGlobal(
SomeService::class,
Binding::createFromServiceName('someService')
@@ -214,6 +244,13 @@ class BindingTest extends BaseTestCase
{
$data = new BindingData();
+ $binder = new Binder($data);
+
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$data->addContext(
SomeClassRequiringValue::class,
'$value',
@@ -252,6 +289,11 @@ class BindingTest extends BaseTestCase
$data = new BindingData();
$binder = new Binder($data);
+ $binder->bindImplementation(
+ CacheItemPoolInterface::class,
+ FileCacheItemPool::class
+ );
+
$binder->bindService(SomeService::class, 'testService');
$binder->bindService(QualifiedClassKey::create(SomeService::class, 'alt'), 'testServiceAlt');
diff --git a/tests/unit/Espo/Core/Utils/DataCacheTest.php b/tests/unit/Espo/Core/Utils/DataCacheTest.php
index b8b4cfb86c..86443e52de 100644
--- a/tests/unit/Espo/Core/Utils/DataCacheTest.php
+++ b/tests/unit/Espo/Core/Utils/DataCacheTest.php
@@ -29,6 +29,7 @@
namespace tests\unit\Espo\Core\Utils;
+use Espo\Core\Utils\Cache\Exceptions\InvalidArgument;
use Espo\Core\Utils\Cache\FileCacheItemPool;
use Espo\Core\Utils\DataCache;
use Espo\Core\Utils\File\Manager as FileManager;
@@ -110,7 +111,7 @@ class DataCacheTest extends TestCase
public function testStoreBadDataType()
{
- $this->expectException(InvalidArgumentException::class);
+ $this->expectException(InvalidArgument::class);
$data = false;