Skip to content

Commit 4be09a4

Browse files
authored
Merge pull request #847 from driehle/drop-doctrine-cache
Dropped support for doctrine/cache ^1.0
2 parents 878f512 + ea067ef commit 4be09a4

File tree

4 files changed

+10
-78
lines changed

4 files changed

+10
-78
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"composer-runtime-api": "^2.0",
4141
"composer/semver": "^3.0",
4242
"doctrine/annotations": "^1.13.3 || ^2",
43-
"doctrine/cache": "^1.13.0 || ^2.1.0",
43+
"doctrine/cache": "^2.1.0",
4444
"doctrine/collections": "^2.0.0",
4545
"doctrine/doctrine-laminas-hydrator": "^3.2.0",
4646
"doctrine/event-manager": "^1.2.0 || ^2.0",
@@ -80,7 +80,9 @@
8080
"doctrine/orm": "2.12.0"
8181
},
8282
"suggest": {
83-
"doctrine/data-fixtures": "Data Fixtures if you want to generate test data or bootstrap data for your deployments"
83+
"doctrine/data-fixtures": "Data Fixtures if you want to generate test data or bootstrap data for your deployments",
84+
"doctrine/doctrine-mongo-odm-module": "For use with Doctrine MongDB ODM",
85+
"doctrine/doctrine-orm-module": "For use with Doctrine ORM"
8486
},
8587
"autoload": {
8688
"psr-4": {

src/Cache/LaminasStorageCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Bridge class that allows usage of a Laminas Cache Storage as a Doctrine Cache
16+
*
17+
* @deprecated 6.2.0 Usage of doctrine/cache is deprecated, please use PSR-6 natively.
1618
*/
1719
class LaminasStorageCache extends CacheProvider
1820
{

src/ConfigProvider.php

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace DoctrineModule;
66

7-
use Composer\InstalledVersions;
8-
use Composer\Semver\VersionParser;
9-
use Doctrine\Common\Cache as DoctrineCache;
107
use DoctrineModule\Cache\LaminasStorageCache;
118
use Laminas\Authentication\Storage\Session as LaminasSessionStorage;
129
use Laminas\Cache\Storage\Adapter\Memory;
@@ -148,67 +145,12 @@ public function getCachesConfig(): array
148145
}
149146

150147
/**
151-
* Use doctrine/cache config, when doctrine/cache:^1.0 is installed, and use laminas/laminas-cache,
152-
* when doctrine/cache:^2.0 is installed, as the latter does not include any cache adapters anymore
148+
* Use laminas/laminas-cache, as doctrine/cache ^2.0 does not include any cache adapters anymore
153149
*
154150
* @return array<non-empty-string,array{class:class-string,instance?:string,namespace?:string,directory?:string}>
155151
*/
156152
private function getDoctrineCacheConfig(): array
157153
{
158-
if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/cache', '^1.0')) {
159-
return [
160-
'apc' => [
161-
'class' => DoctrineCache\ApcCache::class,
162-
'namespace' => 'DoctrineModule',
163-
],
164-
'apcu' => [
165-
'class' => DoctrineCache\ApcuCache::class,
166-
'namespace' => 'DoctrineModule',
167-
],
168-
'array' => [
169-
'class' => DoctrineCache\ArrayCache::class,
170-
'namespace' => 'DoctrineModule',
171-
],
172-
'filesystem' => [
173-
'class' => DoctrineCache\FilesystemCache::class,
174-
'directory' => 'data/DoctrineModule/cache',
175-
'namespace' => 'DoctrineModule',
176-
],
177-
'memcache' => [
178-
'class' => DoctrineCache\MemcacheCache::class,
179-
'instance' => 'my_memcache_alias',
180-
'namespace' => 'DoctrineModule',
181-
],
182-
'memcached' => [
183-
'class' => DoctrineCache\MemcachedCache::class,
184-
'instance' => 'my_memcached_alias',
185-
'namespace' => 'DoctrineModule',
186-
],
187-
'predis' => [
188-
'class' => DoctrineCache\PredisCache::class,
189-
'instance' => 'my_predis_alias',
190-
'namespace' => 'DoctrineModule',
191-
],
192-
'redis' => [
193-
'class' => DoctrineCache\RedisCache::class,
194-
'instance' => 'my_redis_alias',
195-
'namespace' => 'DoctrineModule',
196-
],
197-
'wincache' => [
198-
'class' => DoctrineCache\WinCacheCache::class,
199-
'namespace' => 'DoctrineModule',
200-
],
201-
'xcache' => [
202-
'class' => DoctrineCache\XcacheCache::class,
203-
'namespace' => 'DoctrineModule',
204-
],
205-
'zenddata' => [
206-
'class' => DoctrineCache\ZendDataCache::class,
207-
'namespace' => 'DoctrineModule',
208-
],
209-
];
210-
}
211-
212154
return [
213155
'apcu' => [
214156
'class' => LaminasStorageCache::class,

src/Service/CacheFactory.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
namespace DoctrineModule\Service;
66

7-
use Doctrine\Common\Cache;
8-
use Doctrine\Common\Cache\CacheProvider;
7+
use Doctrine\Common\Cache as DoctrineCache;
98
use DoctrineModule\Cache\LaminasStorageCache;
109
use DoctrineModule\Options\Cache as CacheOptions;
1110
use Psr\Container\ContainerInterface;
@@ -22,7 +21,7 @@ final class CacheFactory extends AbstractFactory
2221
/**
2322
* {@inheritDoc}
2423
*
25-
* @return Cache\Cache
24+
* @return DoctrineCache\Cache
2625
*
2726
* @throws RuntimeException
2827
*/
@@ -54,12 +53,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array|nu
5453
$cache = $container->get($class);
5554
} else {
5655
switch ($class) {
57-
case Cache\FilesystemCache::class:
58-
$cache = new $class($options->getDirectory());
59-
break;
60-
6156
case LaminasStorageCache::class:
62-
case Cache\PredisCache::class:
6357
$cache = new $class($instance);
6458
break;
6559

@@ -69,15 +63,7 @@ public function __invoke(ContainerInterface $container, $requestedName, array|nu
6963
}
7064
}
7165

72-
if ($cache instanceof Cache\MemcacheCache) {
73-
$cache->setMemcache($instance);
74-
} elseif ($cache instanceof Cache\MemcachedCache) {
75-
$cache->setMemcached($instance);
76-
} elseif ($cache instanceof Cache\RedisCache) {
77-
$cache->setRedis($instance);
78-
}
79-
80-
if ($cache instanceof CacheProvider) {
66+
if ($cache instanceof DoctrineCache\CacheProvider) {
8167
$namespace = $options->getNamespace();
8268
if ($namespace) {
8369
$cache->setNamespace($namespace);

0 commit comments

Comments
 (0)