diff --git a/composer.json b/composer.json index 49c62a8..1eb6e6b 100644 --- a/composer.json +++ b/composer.json @@ -47,6 +47,7 @@ "require": { "php": "~8.0.0 || ~8.1.0 || ~8.2.0", "ext-mongodb": "*", + "doctrine/cache": "^1.11 || ^2.0", "doctrine/doctrine-laminas-hydrator": "^3.3.0", "doctrine/doctrine-module": "^6.0.4", "doctrine/event-manager": "^1.2.0 || ^2.0.0", @@ -87,8 +88,8 @@ }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, - "composer/package-versions-deprecated": true + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true }, "platform": { "ext-mongodb": "1.11.0" diff --git a/src/Options/Configuration.php b/src/Options/Configuration.php index 0c00230..1740a23 100644 --- a/src/Options/Configuration.php +++ b/src/Options/Configuration.php @@ -12,6 +12,8 @@ /** * Configuration options for doctrine mongo + * + * @extends AbstractOptions|null> */ final class Configuration extends AbstractOptions { diff --git a/src/Options/Connection.php b/src/Options/Connection.php index 1cb7929..bcfd581 100644 --- a/src/Options/Connection.php +++ b/src/Options/Connection.php @@ -8,6 +8,8 @@ /** * Connection options for doctrine mongo + * + * @extends AbstractOptions */ final class Connection extends AbstractOptions { diff --git a/src/Options/DocumentManager.php b/src/Options/DocumentManager.php index c8d227c..966407a 100644 --- a/src/Options/DocumentManager.php +++ b/src/Options/DocumentManager.php @@ -8,6 +8,8 @@ /** * Document manager options for doctrine mongo + * + * @extends AbstractOptions */ final class DocumentManager extends AbstractOptions { diff --git a/src/Options/MongoLoggerCollector.php b/src/Options/MongoLoggerCollector.php index a334c72..5d624dc 100644 --- a/src/Options/MongoLoggerCollector.php +++ b/src/Options/MongoLoggerCollector.php @@ -8,6 +8,8 @@ /** * Configuration options for a collector + * + * @extends AbstractOptions */ final class MongoLoggerCollector extends AbstractOptions { diff --git a/src/Service/ConfigurationFactory.php b/src/Service/ConfigurationFactory.php index fbf941c..861ccd7 100644 --- a/src/Service/ConfigurationFactory.php +++ b/src/Service/ConfigurationFactory.php @@ -4,6 +4,7 @@ namespace DoctrineMongoODMModule\Service; +use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\ODM\MongoDB\Configuration; use Doctrine\ODM\MongoDB\Types\Type; use DoctrineMongoODMModule\Options; @@ -68,7 +69,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array|nu } // caching - $config->setMetadataCacheImpl($container->get($configurationOptions->getMetadataCache())); + $cache = $container->get($configurationOptions->getMetadataCache()); + $config->setMetadataCache(CacheAdapter::wrap($cache)); // Register filters foreach ($configurationOptions->getFilters() as $alias => $class) { diff --git a/tests/Doctrine/ConfigurationFactoryTest.php b/tests/Doctrine/ConfigurationFactoryTest.php index 3842df9..92eb731 100644 --- a/tests/Doctrine/ConfigurationFactoryTest.php +++ b/tests/Doctrine/ConfigurationFactoryTest.php @@ -5,6 +5,7 @@ namespace DoctrineMongoODMModuleTest\Doctrine; use Doctrine\Common\Cache\Cache; +use Doctrine\Common\Cache\Psr6\CacheAdapter; use Doctrine\ODM\MongoDB\APM\CommandLoggerInterface; use Doctrine\ODM\MongoDB\Configuration as Config; use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionFactory; @@ -99,7 +100,7 @@ public function testCreation(): void $this->assertInstanceOf(Config::class, $config); - $this->assertSame($metadataCache, $config->getMetadataCacheImpl()); + $this->assertEquals(CacheAdapter::wrap($metadataCache), $config->getMetadataCache()); $this->assertSame($mappingDriver, $config->getMetadataDriverImpl()); $this->assertSame(Config::AUTOGENERATE_EVAL, $config->getAutoGenerateProxyClasses());