Problem/Motivation
We have enough information now to build the list of bundles for an entity type automatically if that entity type uses a config entity with the bundle_of annotation key.
The current implementations are full of hacks that directly use the config system as they try to work when the entity types are being built... but there's no reason to do so, as this isn't happening as part of doing that, it's a separate hook and we have the entity type information built and available to use at that point...
Proposed resolution
Loop over entity types in EntityManager::getAllBundleInfo(), build what we can by default.
Remaining tasks
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | bundle-info-2261401-7-interdiff.txt | 1.67 KB | berdir |
| #7 | bundle-info-2261401-7.patch | 5.62 KB | berdir |
| #2 | bundle-info-2261401-2.patch | 5.74 KB | berdir |
| #2 | bundle-info-2261401-2-interdiff.txt | 530 bytes | berdir |
| #1 | bundle-info-2261401-1.patch | 5.8 KB | berdir |
Comments
Comment #1
berdirThis is nice :)
The only remaining hook_entity_bundle_info() implementations in core are:
- comment (can be removed in https://drupal.org/node/2228763)
- menu_ui (a UI module is providing bundles based on an entity defined in system.module for an entity defined in menu_link.. fun :p menu link bundles are also a bit weird, #2177611: Check test coverage for menu link content entities with entity query might clean that up but I have no idea what will happen to menu links now anyway)
- entity_test Uses state to store bundle info, so needs to remain custom.
I also removed the custom caching and stuff in node_type_get_names() and use the available bundle information... A method on the entity manager to get bundle labels would be nice...
Comment #2
berdirAnd now without the debug.
Comment #5
berdir2: bundle-info-2261401-2.patch queued for re-testing.
Comment #7
berdirWell, that was messed up. Need to invert the order and do two loops, first add real bundles and only after that provide defaults for those don't have any.
Not exactly sure how it should behave if there is a bundle entity type but there are no bundles.. but I'm not changing the behavior here...
Comment #8
larowlan+1 RTBC here, great clean up
Comment #9
berdir7: bundle-info-2261401-7.patch queued for re-testing.
Comment #10
tim.plunkettLooks good to me
Comment #11
fagoGreat work, +1
Comment #12
alexpottNice! Committed 82ecfad and pushed to 8.x. Thanks!