Closed mgirouard closed 8 years ago
Any feedback on this? Happy to close if it's not useful!
@mgirouard can you show where/how this would be used?
We ran into a a problem where we didn't have full control over the addFixture()
calls on a Loader. More specifically, we didn't have control over the order in which fixtures were added. Most of our fixtures implement DependentFixtureInterface
so we couldn't rely on constructor.
Instead, we have to do something similar to:
foreach ($loader->getFixtures() as $fixture) {
if ($fixture instanceof Fixtures\Foo) {
$setting = $container->get('settings')['fooSetting'];
$fixture->configureSetting($setting);
break;
}
}
Ideally we can just ask for the fixture by FQCN:
$fixture = $loader->getFixture(Fixtures\Foo::class);
We've tried to restructure a bit, but this seems to be the simplest possible solution.
@Ocramius Seems good to go to me ?
Indeed, good to go.
Thanks all. I'm looking forward to using this right away!
I'm not sure if this is a good idea, but I've run into the case a few times where you need to get a fixture instance you didn't directly instantiate. Most often this happens when one fixture is automatically added by the loader as a dependency on another fixture.