doctrine / DoctrineFixturesBundle

Symfony integration for the doctrine/data-fixtures library
MIT License
2.44k stars 202 forks source link

Add an entrypoint to use a custom ReferenceRepository #386

Open VincentLanglet opened 1 year ago

VincentLanglet commented 1 year ago

Hi !

I'd like to use a custom ReferenceRepository (https://github.com/doctrine/data-fixtures/blob/1.6.x/src/ReferenceRepository.php),

Currently:

I see two way/improvements to solve my issue: 1) Solving https://github.com/doctrine/DoctrineFixturesBundle/issues/380 to allow using custom fixtures loaders, then my FixtureLoader will do

$fixture = new class();
$fixture->setReferenceRepository($myCustomRepository);

AND I'll need to add a check in the AbstractExecutor (https://github.com/doctrine/data-fixtures/blob/1.6.x/src/Executor/AbstractExecutor.php#L119) to not set the ReferenceRepository if one is already set (But how do I know this since currently no method is exposed ?)

2) Solving https://github.com/doctrine/DoctrineFixturesBundle/issues/364 by allowing to use ExecutorFactories in order to use a custom executor. My factory will just do:

$executor = new ORMExecutor($em, $purger);
$executor->setReferenceRepository($myCustomRepository);

What do you think of this problem ? Any suggestion/preferred solution @greg0ire @derrabus ? Thanks