Skip to content

Commit aaa20e3

Browse files
authored
Allow fixtures loader custom implementation (#510)
1 parent 954aa87 commit aaa20e3

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

config/services.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66

77
<!-- commands -->
88
<service id="doctrine.fixtures_load_command" class="Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand">
9-
<argument type="service" id="doctrine.fixtures.loader" />
9+
<argument type="service" id="doctrine.fixtures.provider" />
1010
<argument type="service" id="doctrine" />
1111
<tag name="console.command" command="doctrine:fixtures:load" />
1212
</service>
1313

14-
<service id="doctrine.fixtures.loader" class="Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader" public="false">
15-
<argument type="service" id="service_container" />
16-
</service>
14+
<service id="doctrine.fixtures.provider" alias="doctrine.fixtures.loader" />
15+
<service id="doctrine.fixtures.loader" class="Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader" />
1716

18-
<service id="doctrine.fixtures.purger.orm_purger_factory" class="Doctrine\Bundle\FixturesBundle\Purger\ORMPurgerFactory" public="false">
17+
<service id="doctrine.fixtures.purger.orm_purger_factory" class="Doctrine\Bundle\FixturesBundle\Purger\ORMPurgerFactory">
1918
<tag name="doctrine.fixtures.purger_factory" alias="default"/>
2019
</service>
2120
</services>

src/Command/LoadDataFixturesDoctrineCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;
88
use Doctrine\Bundle\FixturesBundle\DependencyInjection\CompilerPass\PurgerFactoryCompilerPass;
9-
use Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader;
9+
use Doctrine\Bundle\FixturesBundle\Loader\FixturesProvider;
1010
use Doctrine\Bundle\FixturesBundle\Purger\ORMPurgerFactory;
1111
use Doctrine\Bundle\FixturesBundle\Purger\PurgerFactory;
1212
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
@@ -30,7 +30,7 @@ final class LoadDataFixturesDoctrineCommand extends DoctrineCommand
3030
{
3131
/** @param PurgerFactory[] $purgerFactories */
3232
public function __construct(
33-
private SymfonyFixturesLoader $fixturesLoader,
33+
private FixturesProvider $fixturesLoader,
3434
ManagerRegistry $doctrine,
3535
/** @var array<string, ORMPurgerFactory> $purgerFactories */
3636
private array $purgerFactories = [],

src/Loader/FixturesProvider.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Bundle\FixturesBundle\Loader;
6+
7+
use Doctrine\Common\DataFixtures\FixtureInterface;
8+
9+
interface FixturesProvider
10+
{
11+
/**
12+
* @param string[] $groups
13+
*
14+
* @return FixtureInterface[]
15+
*/
16+
public function getFixtures(array $groups = []): array;
17+
}

src/Loader/SymfonyFixturesLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use function get_class;
1818
use function sprintf;
1919

20-
final class SymfonyFixturesLoader extends Loader
20+
final class SymfonyFixturesLoader extends Loader implements FixturesProvider
2121
{
2222
/** @var FixtureInterface[] */
2323
private array $loadedFixtures = [];

0 commit comments

Comments
 (0)