From 983ec4c642da3c6141c2f01cf63251a46b1f4a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 20 Dec 2023 10:18:04 +0100 Subject: [PATCH] Remove deprecated parameters (#821) --- .../DeprecateChangedClassParametersPass.php | 87 ------------------- .../DoctrineMongoDBExtension.php | 10 ++- DoctrineMongoDBBundle.php | 2 - Resources/config/mongodb.php | 16 ---- ...eprecateChangesClassParametersPassTest.php | 29 ------- UPGRADE-5.0.md | 4 + 6 files changed, 13 insertions(+), 135 deletions(-) delete mode 100644 DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php delete mode 100644 Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php diff --git a/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php b/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php deleted file mode 100644 index 4b63f5cf..00000000 --- a/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php +++ /dev/null @@ -1,87 +0,0 @@ - Client::class, - 'doctrine_mongodb.odm.configuration.class' => Configuration::class, - 'doctrine_mongodb.odm.document_manager.class' => DocumentManager::class, - 'doctrine_mongodb.odm.manager_configurator.class' => ManagerConfigurator::class, - 'doctrine_mongodb.odm.event_manager.class' => ContainerAwareEventManager::class, - 'doctrine_odm.mongodb.validator_initializer.class' => DoctrineInitializer::class, - 'doctrine_odm.mongodb.validator.unique.class' => UniqueEntityValidator::class, - 'doctrine_mongodb.odm.class' => ManagerRegistry::class, - 'doctrine_mongodb.odm.security.user.provider.class' => EntityUserProvider::class, - 'doctrine_mongodb.odm.proxy_cache_warmer.class' => ProxyCacheWarmer::class, - 'doctrine_mongodb.odm.hydrator_cache_warmer.class' => HydratorCacheWarmer::class, - 'doctrine_mongodb.odm.persistent_collection_cache_warmer.class' => PersistentCollectionCacheWarmer::class, - ] as $parameter => $class - ) { - if (! $container->hasParameter($parameter) || $container->getParameter($parameter) === $class) { - continue; - } - - trigger_deprecation( - 'doctrine/mongodb-odm-bundle', - '4.7', - '"%s" parameter is deprecated, use a compiler pass to update the service instead.', - $parameter, - ); - } - - foreach ( - [ - 'doctrine_mongodb.odm.cache.array.class' => 'Doctrine\Common\Cache\ArrayCache', - 'doctrine_mongodb.odm.cache.apc.class' => 'Doctrine\Common\Cache\ApcCache', - 'doctrine_mongodb.odm.cache.apcu.class' => 'Doctrine\Common\Cache\ApcuCache', - 'doctrine_mongodb.odm.cache.memcache.class' => 'Doctrine\Common\Cache\MemcacheCache', - 'doctrine_mongodb.odm.cache.memcache_host' => 'localhost', - 'doctrine_mongodb.odm.cache.memcache_port' => 11211, - 'doctrine_mongodb.odm.cache.memcache_instance.class' => 'Memcache', - 'doctrine_mongodb.odm.cache.xcache.class' => 'Doctrine\Common\Cache\XcacheCache', - 'doctrine_mongodb.odm.metadata.driver_chain.class' => MappingDriverChain::class, - 'doctrine_mongodb.odm.metadata.attribute.class' => AttributeDriver::class, - 'doctrine_mongodb.odm.metadata.xml.class' => XmlDriver::class, - ] as $parameter => $class - ) { - if (! $container->hasParameter($parameter) || $container->getParameter($parameter) === $class) { - continue; - } - - trigger_deprecation( - 'doctrine/mongodb-odm-bundle', - '4.7', - '"%s" parameter is deprecated, this parameter is used internally for configuration.', - $parameter, - ); - } - } -} diff --git a/DependencyInjection/DoctrineMongoDBExtension.php b/DependencyInjection/DoctrineMongoDBExtension.php index 494960fa..0ef62034 100644 --- a/DependencyInjection/DoctrineMongoDBExtension.php +++ b/DependencyInjection/DoctrineMongoDBExtension.php @@ -12,11 +12,14 @@ use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass; use Doctrine\Bundle\MongoDBBundle\EventSubscriber\EventSubscriberInterface; use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface; +use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver; use Doctrine\Bundle\MongoDBBundle\Repository\ServiceDocumentRepositoryInterface; use Doctrine\Common\DataFixtures\Loader as DataFixturesLoader; use Doctrine\Common\EventSubscriber; use Doctrine\ODM\MongoDB\Configuration as ODMConfiguration; use Doctrine\ODM\MongoDB\DocumentManager; +use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; +use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use InvalidArgumentException; use MongoDB\Client; use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension; @@ -534,7 +537,12 @@ protected function getMappingResourceExtension(): string protected function getMetadataDriverClass(string $driverType): string { - return '%' . $this->getObjectManagerElementName('metadata.' . $driverType . '.class') . '%'; + return match ($driverType) { + 'driver_chain' => MappingDriverChain::class, + 'attribute' => AttributeDriver::class, + 'xml' => XmlDriver::class, + default => throw new InvalidArgumentException(sprintf('Metadata driver not supported: "%s"', $driverType)) + }; } public function getAlias(): string diff --git a/DoctrineMongoDBBundle.php b/DoctrineMongoDBBundle.php index 1253f054..4c656e8a 100644 --- a/DoctrineMongoDBBundle.php +++ b/DoctrineMongoDBBundle.php @@ -6,7 +6,6 @@ use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\CreateHydratorDirectoryPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\CreateProxyDirectoryPass; -use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DeprecateChangedClassParametersPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\FixturesCompilerPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass; use Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension; @@ -41,7 +40,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new DoctrineValidationPass('mongodb')); $container->addCompilerPass(new ServiceRepositoryCompilerPass()); $container->addCompilerPass(new FixturesCompilerPass()); - $container->addCompilerPass(new DeprecateChangedClassParametersPass()); if (! $container->hasExtension('security')) { return; diff --git a/Resources/config/mongodb.php b/Resources/config/mongodb.php index 16c36cb0..2aa06a61 100644 --- a/Resources/config/mongodb.php +++ b/Resources/config/mongodb.php @@ -5,12 +5,9 @@ use Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoader; use Doctrine\Bundle\MongoDBBundle\ManagerConfigurator; use Doctrine\Bundle\MongoDBBundle\ManagerRegistry; -use Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver; use Doctrine\Bundle\MongoDBBundle\Repository\ContainerRepositoryFactory; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver; use Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener; -use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use ProxyManager\Proxy\GhostObjectInterface; use Symfony\Bridge\Doctrine\ContainerAwareEventManager; use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; @@ -20,19 +17,6 @@ use function Symfony\Component\DependencyInjection\Loader\Configurator\service; return static function (ContainerConfigurator $containerConfigurator): void { - $containerConfigurator->parameters() - ->set('doctrine_mongodb.odm.cache.array.class', 'Doctrine\Common\Cache\ArrayCache') - ->set('doctrine_mongodb.odm.cache.apc.class', 'Doctrine\Common\Cache\ApcCache') - ->set('doctrine_mongodb.odm.cache.apcu.class', 'Doctrine\Common\Cache\ApcuCache') - ->set('doctrine_mongodb.odm.cache.memcache.class', 'Doctrine\Common\Cache\MemcacheCache') - ->set('doctrine_mongodb.odm.cache.memcache_host', 'localhost') - ->set('doctrine_mongodb.odm.cache.memcache_port', 11211) - ->set('doctrine_mongodb.odm.cache.memcache_instance.class', 'Memcache') - ->set('doctrine_mongodb.odm.cache.xcache.class', 'Doctrine\Common\Cache\XcacheCache') - ->set('doctrine_mongodb.odm.metadata.driver_chain.class', MappingDriverChain::class) - ->set('doctrine_mongodb.odm.metadata.attribute.class', AttributeDriver::class) - ->set('doctrine_mongodb.odm.metadata.xml.class', XmlDriver::class); - $containerConfigurator->services() ->alias(DocumentManager::class, 'doctrine_mongodb.odm.document_manager') diff --git a/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php b/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php deleted file mode 100644 index 0ef57cb5..00000000 --- a/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php +++ /dev/null @@ -1,29 +0,0 @@ -setParameter('doctrine_mongodb.odm.connection.class', stdClass::class); - - $container->addCompilerPass(new DeprecateChangedClassParametersPass()); - - $this->expectDeprecation('Since doctrine/mongodb-odm-bundle 4.7: "doctrine_mongodb.odm.connection.class" parameter is deprecated, use a compiler pass to update the service instead.'); - - $container->compile(); - } -} diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 6fb6fd95..9b9c5aee 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -14,6 +14,10 @@ UPGRADE FROM 4.x to 5.0 used directly or extended. * Remove support of Annotation mapping, you should use Attributes or XML instead. +## Configuration + +Remove all `doctrine_mongodb.odm.*` parameters. + ## Fixtures * Remove `--service` option from `doctrine:mongodb:fixtures:load` command