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 10, 2023
1 parent b07f049 commit 5963c82
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
11 changes: 0 additions & 11 deletions Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
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;
Expand All @@ -28,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 @@ -67,10 +60,6 @@ public function addFixture(FixtureInterface $fixture): void
$this->addGroupsFixtureMapping($class, $fixture::getGroups());
}

if ($fixture instanceof ContainerAwareInterface) {
$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 5963c82

Please sign in to comment.