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

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new5.8 KB

This 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...

berdir’s picture

StatusFileSize
new530 bytes
new5.74 KB

And now without the debug.

The last submitted patch, 1: bundle-info-2261401-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: bundle-info-2261401-2.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review

2: bundle-info-2261401-2.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2: bundle-info-2261401-2.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new5.62 KB
new1.67 KB

Well, 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...

larowlan’s picture

+1 RTBC here, great clean up

berdir’s picture

7: bundle-info-2261401-7.patch queued for re-testing.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me

fago’s picture

Great work, +1

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Nice! Committed 82ecfad and pushed to 8.x. Thanks!

  • Commit 82ecfad on 8.x by alexpott:
    Issue #2261401 by Berdir: Automatically provide bundle info/list based...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.