Coming over from #1115510: Entity providing modules must call field_attach_delete_bundle() in hook_uninstall().
webchick asked in irc whether we could make the test generic. That would be a good idea, but I don't think it's doable at the moment.
The test would look something like this:
Enable all modules available.
Create at least one bundle for each entity type.
Add a field instance to each bundle.
Disable all the modules.
Uninstall all the modules.
Re-enable all the modules.
Add a same-named bundle to all entity types again.
Recreate the field(s).
Create field instances to all the entity types again.
This is all doable except for the "Create at least one bundle for each entity type." which is completely non standard at the moment.
node_type_save() (which magically creates bundles for comments too, who's idea was that?!?)
taxonomy_vocabulary_save()
etc. etc.
It would be good to standardize this stuff, bundles are a bit messy at the moment in general, so opening a new task.
Comments
Comment #1
webchickJust a note that when/if this is done, we should remove + function testUninstallReinstall() { from taxonomy.test.
Comment #2
yched CreditAttribution: yched commentedSubscribe
Comment #3
fago>"Create at least one bundle for each entity type."
I don't think this is easy to standardize, except when we turn bundles also into entity objects. Once we have that we just need to know the entity type and then can rely upon it to create those bundle objects.
Comment #4
yched CreditAttribution: yched commentedFor the record, the f_a_[CRD]_bundle() functions (and associated hooks) are part of those API funcs introduced by the Field API patch *before* an official Entity API got in, that would IMO belong to the Entity API instead. "Bundles" are not a notion exclusive to Field API - and an entity type can definitely have "bundles" without being fieldable.
Managing bundles should be the job of entity_create_bundle(), and the current code in f_a_create_bundle() should be in field.module's implementation of hook_entity_create_bundle().
Comment #5
fmizzell CreditAttribution: fmizzell commentedI truly thought it was. I know that bundles have become synonymous with "type" or "subtype", but they truly are a contraption useful only to attach different sets of fields to one entity type. How would a non-fieldable entity type use multiple bundles?
Comment #6
andypostSuppose better to make this a methods (createSubType() and other) of entity.manager
Also interesting thoughts about in #1380720: Rename entity "bundle" to "subtype" in the UI text and help
Comment #19
catchBundle creation is still per-entity type and there's no plans to change it, if there were, we should start again.