-
-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject Fixtures loaders #242
Comments
From my perspective, the Thoughts? |
So to recap,
The issue is that the loader is instantiated and there's not much that can be done since we're in a static context, unless we pass the loader in the Back to our cases: having a custom So here's my proposal:
I would like 2. of course, it opens up the library without being much to maintain. But obviously, if you can prefer to let this to the initiative of the users and choose 1. If you're fine with 2, I can take care of the PR. |
Rather than introducing new static classes and yet another interface to the library, I think better documentation is the right answer. Unless I'm missing something, the following should work in even the most complicated circumstance: $loader = new Loader();
/* any custom additions the user needs to $loader */
$persister = new DoctrinePersister($om);
$persister->persist($loader->load($fixtures)); That doesn't strike me as too much to ask of someone needing specific control, and doesn't expand ways to use the library even more.
Would love to hear your thoughts. |
Well, what does not really please me is that's kind of incomplete. This library provides a fixtures loader, which basically generate objects from files and a persistance layer via the The issue risen here is the last part: due to being used statically it cannot be reused. What I would prefer is, having a "clean" Fixtures non static, which does the work properly with the loader injected. Then the static Fixtures would be refactored to use the non static one and avoid duplication. That way you have the convenient Fixtures helper but also another one that can be used in another context like Laravel or Symfony. You said there is not much, I agree for now so a doc may be fine. But depending of the other issues risen, especially #257 that may change. So for now I would say let's keep this and see how it goes. |
In the end is very unlikely, will be changed in v3. |
As of now, when calling
Nelmio\Alice\Fixtures::loadFiles()
, the loader is resolved with the following function:But what if we want to use a custom Loader? A brand new loader or for example a
Nelmio\Alice\Fixtures\Loader
which has been initialised with some parameters.The text was updated successfully, but these errors were encountered: