diff --git a/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php b/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php new file mode 100644 index 00000000..4b63f5cf --- /dev/null +++ b/DependencyInjection/Compiler/DeprecateChangedClassParametersPass.php @@ -0,0 +1,87 @@ + 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/DoctrineMongoDBBundle.php b/DoctrineMongoDBBundle.php index bd88f530..d50a2451 100644 --- a/DoctrineMongoDBBundle.php +++ b/DoctrineMongoDBBundle.php @@ -7,6 +7,7 @@ use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\CacheCompatibilityPass; 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; @@ -43,6 +44,7 @@ public function build(ContainerBuilder $container) $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/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php b/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php new file mode 100644 index 00000000..0ef57cb5 --- /dev/null +++ b/Tests/DependencyInjection/Compiler/DeprecateChangesClassParametersPassTest.php @@ -0,0 +1,29 @@ +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-4.7.md b/UPGRADE-4.7.md index b61cef99..36ae8c40 100644 --- a/UPGRADE-4.7.md +++ b/UPGRADE-4.7.md @@ -11,3 +11,28 @@ UPGRADE FROM 4.6 to 4.7 * The `doctrine_mongodb.odm.fixture_loader` parameter has been removed. * Implementing `ContainerAwareInterface` on fixtures classes is deprecated, use dependency injection instead. +* Deprecated the following `*.class` parameters, you should use a compiler pass to update the service instead: + * `doctrine_mongodb.odm.connection.class` + * `doctrine_mongodb.odm.configuration.class` + * `doctrine_mongodb.odm.document_manager.class` + * `doctrine_mongodb.odm.manager_configurator.class` + * `doctrine_mongodb.odm.event_manager.class` + * `doctrine_odm.mongodb.validator_initializer.class` + * `doctrine_odm.mongodb.validator.unique.class` + * `doctrine_mongodb.odm.class` + * `doctrine_mongodb.odm.security.user.provider.class` + * `doctrine_mongodb.odm.proxy_cache_warmer.class` + * `doctrine_mongodb.odm.hydrator_cache_warmer.class` + * `doctrine_mongodb.odm.persistent_collection_cache_warmer.class` +* Deprecated modifying the following parameters, they are used internally: + * `doctrine_mongodb.odm.cache.array.class` + * `doctrine_mongodb.odm.cache.apc.class` + * `doctrine_mongodb.odm.cache.apcu.class` + * `doctrine_mongodb.odm.cache.memcache.class` + * `doctrine_mongodb.odm.cache.memcache_host` + * `doctrine_mongodb.odm.cache.memcache_port` + * `doctrine_mongodb.odm.cache.memcache_instance.class` + * `doctrine_mongodb.odm.cache.xcache.class` + * `doctrine_mongodb.odm.metadata.driver_chain.class` + * `doctrine_mongodb.odm.metadata.attribute.class` + * `doctrine_mongodb.odm.metadata.xml.class`