Skip to content

Commit

Permalink
Remove container injection in fixture classes with ContainerAwareInte…
Browse files Browse the repository at this point in the history
…rface
  • Loading branch information
GromNaN committed Dec 11, 2023
1 parent 0f6d04c commit 49cdb3d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
14 changes: 0 additions & 14 deletions Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@
use LogicException;
use ReflectionClass;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

use function array_key_exists;
use function array_values;
use function get_class;
use function sprintf;
use function trigger_deprecation;

final class SymfonyFixturesLoader extends Loader implements SymfonyFixturesLoaderInterface
{
Expand All @@ -29,11 +26,6 @@ final class SymfonyFixturesLoader extends Loader implements SymfonyFixturesLoade
/** @var array<string, array<string, bool>> */
private array $groupsFixtureMapping = [];

public function __construct(
private ContainerInterface $container,
) {
}

/**
* @internal
*
Expand Down Expand Up @@ -68,12 +60,6 @@ public function addFixture(FixtureInterface $fixture): void
$this->addGroupsFixtureMapping($class, $fixture::getGroups());
}

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);
}

parent::addFixture($fixture);
}

Expand Down
4 changes: 1 addition & 3 deletions Resources/config/mongodb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@
<!-- listeners -->
<service id="doctrine_mongodb.odm.listeners.resolve_target_document" class="%doctrine_mongodb.odm.listeners.resolve_target_document.class%" public="false" />

<service id="doctrine_mongodb.odm.symfony.fixtures.loader" class="Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoader" public="false">
<argument type="service" id="service_container" />
</service>
<service id="doctrine_mongodb.odm.symfony.fixtures.loader" class="Doctrine\Bundle\MongoDBBundle\Loader\SymfonyFixturesLoader" public="false" />
</services>
</container>
2 changes: 2 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ UPGRADE FROM 4.x to 5.0
used directly or extended.
* Remove support of Annotation mapping, you should use Attributes or XML instead.
* Remove `--service` option from `doctrine:mongodb:fixtures:load` command
* Remove automatic injection of the container in fixtures classes implementing
`ContainerAwareInterface`. You should use dependency injection instead.
5 changes: 0 additions & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
<code>children</code>
</UndefinedMethod>
</file>
<file src="Loader/SymfonyFixturesLoader.php">
<ContainerDependency>
<code>private ContainerInterface $container</code>
</ContainerDependency>
</file>
<file src="Tests/Form/Type/GuesserTestType.php">
<MissingTemplateParam>
<code>GuesserTestType</code>
Expand Down

0 comments on commit 49cdb3d

Please sign in to comment.