Closed noemiquezada closed 5 years ago
Hey guys!
I'm very happy to see this feature finally re-added / fixed in #255 and #256 :D. After seeing #255, I worked with @noemiquezada to change the implementation detail part. Basically, I think the having this interface is a little bit better DX than a tag. Specifically:
In #256
FixtureGroupInterface
and return the groups you wantIn #255
services.yaml
and add the tag:services:
App\DataFixtures\MyFixture:
- { name: doctrine.fixture.orm, tag: main }
However, another option is to combine #255 and #256 to allow either the tag approach OR the new interface.
Cheers!
Hi.
I would very much vote for keeping a tag in the service definition as an optional way to group the fixtures. That way you can easily group a whole directory of fixtures with the same group-tag without changing each individual fixture.
Apart from feedback above, I believe both approaches to be equally valid: as mentioned before, specifying the groups in the container via a service tag would allow assigning a group to all fixtures from a specific directory, while the solution via an interface causes less configuration overhead. However, I would like to avoid having two different ways to achieve one thing.
Having the groups in the code would be preferable, but I'd also argue that if it's not handled in the container, this should be in doctrine/migrations, not in the bundle.
I think it is one of Symfony's strengths that it does not try to contrain developers to "One True Way". Having more than one way to do things I think is the right thing for symfony, when some developers would prefer one way and others would prefer another way.
I for one, would be very disappointed if I could not have a simple way to group all fixtures that where in the same directory.
I like this approach more since it's possible to easily reuse groups as e.g. consts, so having both would be great.
Both approaches have been combined in #260 - and original authors' work + commits were maintained :)
This builds off of #255
It's the same idea, but you group your fixtures via an interface instead of tag. The improvement is developer experience, you stay in the Fixture class instead of needing to re-register the service in order to give it the tag.