KnpLabs / KnpRadBundle

Rapid Application Development for Symfony2 [UNMAINTAINED]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enabling configuration of alice fixtures loading

tentacode opened this issue · comments

I've had the need twice, so maybe there is something that can be done :)

Right now the LoadAliceFixture class is located in Knp\RadBundle\DataFixtures\ORM and I don't see a way to extend it, but as I said I had the need twice to use a custom Faker provider as described on alice documentation

I see two ways of doing this :

  • Moving the LoadAliceFixture class to App at project generation, if we think it's part of the custom project and should not be generic (that's what I think), but it would break BC on existing projects
  • At least enabling setting alice options, like custom providers with some config, but alas I think we should have full control of the fixture loading.

Then again I might have missed something and am open to any other solution 🐼

maybe we should move to preexisting alice bundles ?

if others bundles don't do what you need, then, yes there is definitly room for imporvements.
We should cut this monolitic, hardcoded peace of code that is the LoadAliceFixture class into a configurable, reusable one. it could be done without breaking compat.

Nevermind it is totally doable due to this smart line I did not read :

        $refl = new \ReflectionClass($bundles['App']);
        if (class_exists($customClass = $refl->getNamespaceName().'\\DataFixtures\\ORM\\LoadAliceFixtures') &&
            $customClass !== get_class($this)) {
            return;
        }

RAD LoadAliceFixtures already check if there is an existing LoadAliceFixtures in App, and does not load anything if it has been "extended". My bad and good work guys for thinking about this :)

Yet maybe there is room for improvement on the base LoadAliceFixtures class in RAD (there is always I guess :D)