API-Skeletons / zf-doctrine-data-fixture

Doctrine Data Fixture Console Route with Service Manager configured Fixtures
BSD 2-Clause "Simplified" License
9 stars 4 forks source link

DependentFixtureInterface not supported correctly #12

Closed internalsystemerror closed 6 years ago

internalsystemerror commented 6 years ago

(As stated in the readme) If I have the following configuration:

return [
    'doctrine' => [
        'fixture' => [
            'orm_default' => [
                'factories' => [
                    DependentFixture::class => DependentFixtureFactory::class,
                    StandardFixture::class  => StandardFixtureFactory::class,
                ],
            ],
        ],
    ],
];

with DependentFixure implementing Doctrine\Common\DataFixtures\DependentFixtureInterface and having StandardFixture as a dependency, then due to https://github.com/doctrine/data-fixtures/blob/v1.1.1/lib/Doctrine/Common/DataFixtures/Loader.php#L138 the StandardFixture is added first via the loader as a simple $this->addFixture(new $class);.

The best solution I can propose on first glance is to update to doctrine/data-fixture version 1.3 and extend the loader overriding the createFixture($class) method to retrieve the fixture from the service manager.

If you're happy with this approach, I can look at providing a PR with test and implementation.