Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Updated: Comment #10
Problem/Motivation
To help general DX/code organisation bring entity bundle logic into the EntityManager. This will benefit unit testing (mocking etc..) and remove the need for calling a procedural function.
Proposed resolution
Convert entity_get_bundles() function in entity.inc to methods on the EntityManager. Add getBundleInfo() and getAllBundleInfo(), the module handler is already injected into EntityManager so we can use that.
Remaining tasks
None, patch ready.
User interface changes
None
API changes
Deprecate entity_get_bundles() in favour of new methods?
Original report by @dawehner
Comment | File | Size | Author |
---|---|---|---|
#8 | 2030151-8.patch | 5 KB | damiankloip |
#8 | interdiff-2030151-8.txt | 1.26 KB | damiankloip |
#12 | 2030151-12.patch | 5.15 KB | damiankloip |
#12 | interdiff-2030151-12.txt | 519 bytes | damiankloip |
#6 | 2030151-6.patch | 4.28 KB | damiankloip |
Comments
Comment #1
dawehnerThere we go.
Comment #3
damiankloip CreditAttribution: damiankloip commentedThe bundle labels were still using $bundles variable, and we need to clear the bundleInfo static cache when the entity info definitions are cleared.
Comment #4
damiankloip CreditAttribution: damiankloip commentedTim kindly pointed out that I had accidentally included the whole world in the last patch. interdiff is still good!
Comment #6
damiankloip CreditAttribution: damiankloip commentedok, lets try once more. Interdiff in #3 is still correct.
Comment #8
damiankloip CreditAttribution: damiankloip commentedForgot about this issue, rerolled and fixed the remaining failures in EntityReferenceAdminTest. Not sure why the current tests failed without this fix though... Using key() to get the bundle after iterating over it will return NULL as there is no current key to return.
Comment #9
dawehnerAll looks fine beside the missing issue summary.
Comment #10
dawehnerThank you
Comment #11
alexpottI think we need at least an @see here to the new getBundleInfo and getAllBundleInfo methods.
Comment #12
damiankloip CreditAttribution: damiankloip commentedThere we go.
Comment #13
dawehnerThe feedback from alex got adressed, so back to RTBC
Comment #14
alexpottCommitted ea8a4bd and pushed to 8.x. Thanks!
Comment #15.0
(not verified) CreditAttribution: commentedAdded proper issue summary
Comment #16
YesCT CreditAttribution: YesCT commentedShall we have a follow-up to actually replace entity_get_bundles() that already exist in core?
Comment #17
Mile23Yes. :-) #2427637: Remove usages of deprecated entity_get_bundles()
Comment #18
Mile23Added: #2526462: Mark entity_get_bundles() as @deprecated for 9.x.