From c53d1477823eeee60ab089ceffb7f113780e039d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 11 Dec 2023 07:57:53 +0100 Subject: [PATCH] Deprecate container injection in fixture classes with ContainerAwareInterface (#801) --- Loader/SymfonyFixturesLoader.php | 3 +++ UPGRADE-4.7.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Loader/SymfonyFixturesLoader.php b/Loader/SymfonyFixturesLoader.php index 9c5e802e..22c141aa 100644 --- a/Loader/SymfonyFixturesLoader.php +++ b/Loader/SymfonyFixturesLoader.php @@ -19,6 +19,7 @@ use function array_values; use function get_class; use function sprintf; +use function trigger_deprecation; final class SymfonyFixturesLoader extends Loader implements SymfonyFixturesLoaderInterface { @@ -68,6 +69,8 @@ public function addFixture(FixtureInterface $fixture): void } if ($fixture instanceof ContainerAwareInterface) { + trigger_deprecation('doctrine/mongodb-odm-bundle', '4.7', 'Implementing "%s" with "%s" is deprecated, use dependency injection instead.', ContainerAwareInterface::class, FixtureInterface::class); + $fixture->setContainer($this->container); } diff --git a/UPGRADE-4.7.md b/UPGRADE-4.7.md index 743807b6..b61cef99 100644 --- a/UPGRADE-4.7.md +++ b/UPGRADE-4.7.md @@ -9,3 +9,5 @@ UPGRADE FROM 4.6 to 4.7 * The `fixture_loader` configuration option was deprecated and will be removed in 5.0. * The `doctrine_mongodb.odm.fixture_loader` parameter has been removed. +* Implementing `ContainerAwareInterface` on fixtures classes is deprecated, + use dependency injection instead.