Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate modifying class parameters #811

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,32 @@

use Doctrine\Bundle\MongoDBBundle\Attribute\AsDocumentListener;
use Doctrine\Bundle\MongoDBBundle\Attribute\MapDocument;
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\HydratorCacheWarmer;
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\PersistentCollectionCacheWarmer;
use Doctrine\Bundle\MongoDBBundle\CacheWarmer\ProxyCacheWarmer;
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\FixturesCompilerPass;
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass;
use Doctrine\Bundle\MongoDBBundle\EventSubscriber\EventSubscriberInterface;
use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
use Doctrine\Bundle\MongoDBBundle\ManagerConfigurator;
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;
use Doctrine\Bundle\MongoDBBundle\Repository\ServiceDocumentRepositoryInterface;
use Doctrine\Common\Cache\MemcacheCache;
use Doctrine\Common\Cache\RedisCache;
use Doctrine\Common\DataFixtures\Loader as DataFixturesLoader;
use Doctrine\Common\EventSubscriber;
use Doctrine\ODM\MongoDB\Configuration as MongoDBConfiguration;
use Doctrine\ODM\MongoDB\DocumentManager;
use InvalidArgumentException;
use Jean85\PrettyVersions;
use MongoDB\Client;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
use Symfony\Bridge\Doctrine\ContainerAwareEventManager;
use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension;
use Symfony\Bridge\Doctrine\Messenger\DoctrineClearEntityManagerWorkerSubscriber;
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Symfony\Bridge\Doctrine\Validator\DoctrineInitializer;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
Expand All @@ -44,6 +55,7 @@
use function in_array;
use function interface_exists;
use function is_dir;
use function method_exists;
use function reset;
use function sprintf;

Expand Down Expand Up @@ -147,6 +159,8 @@ public function load(array $configs, ContainerBuilder $container)
$this->loadMessengerServices($container);

$this->loadEntityValueResolverServices($container, $loader, $config);

$this->deprecateClassParameters($container);
}

/**
Expand Down Expand Up @@ -661,4 +675,35 @@ private static function getODMVersion(): string

return self::$odmVersion;
}

private function deprecateClassParameters(ContainerBuilder $container): void
{
if (! method_exists($container, 'deprecateParameter')) {
return;
}

foreach (
[
'doctrine_mongodb.odm.connection.class' => Client::class,
'doctrine_mongodb.odm.configuration.class' => MongoDBConfiguration::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
) {
$container->deprecateParameter(
$parameter,
'doctrine/mongodb-odm-bundle',
'4.7',
'"%s" parameter is deprecated, you should use a compiler pass to update the service instead.',
);
}
}
}
13 changes: 13 additions & 0 deletions UPGRADE-4.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@ 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`
Loading