Allow bundle entity to be used for more than one content entity

Created on 9 January 2021, almost 4 years ago
Updated 12 August 2024, 5 months ago

Problem/Motivation

Right now, a bundle config entity type could serve as bundle only for one content entity type. E.g. node_type is used for node but cannot be used by a custom content entity type in the same time with node. Some contrib/custom modules show that it's a real use-case to have a bundle config entity type shared across many content entity types. See the Entity Pilot case.

Recently, I hit a case when I need a new content entity type that extends taxonomy_term. But I still want to use vocabulary as bundle for the new entity type while it remains available for core, taxonomy_term, term entity type. The two content entities should coexist and share the same bundle config entities.

The limitation is by design, as the bundle entity type bundle_of annotation is a string rather than an array of strings.

Proposed resolution

  • Replace the EntityTypeInterface::getBundleOf() with a new EntityTypeInterface::getBundleOfEntityTypeIds() method that returns an array of content entity type IDs.
  • Deprecate EntityTypeInterface::getBundleOf().
  • Deprecate declaring the bundle_of annotation as sting.

To be decided: How to resolve the field_ui_entity_operation() case, where there the content entity type context lacks, so there's now way to figure out which is content the entity type to pick up.

Remaining tasks

Figure out how to handle the field_ui_entity_operation() case.

User interface changes

None.

API changes

  • New EntityTypeInterface::getBundleOf() method.
  • EntityTypeInterface::getBundleOf() is deprecated.
  • Declaring bundle_of annotation as sting is deprectaed.

Data model changes

None.

Release notes snippet

TBD.

Feature request
Status

Closed: won't fix

Version

10.1

Component
Entity 

Last updated about 16 hours ago

Created by

🇷🇴Romania claudiu.cristea Arad 🇷🇴

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !232Resolve #3191814 "Allow bundle entity" → (Closed) created by claudiu.cristea
  • Pipeline finished with Failed
    4 months ago
    Total: 452s
    #269602
  • Pipeline finished with Failed
    4 months ago
    #269608
  • Pipeline finished with Failed
    4 months ago
    Total: 497s
    #269618
  • Pipeline finished with Success
    4 months ago
    Total: 408s
    #269631
  • Pipeline finished with Success
    4 months ago
    Total: 435s
    #269672
  • Pipeline finished with Success
    3 months ago
    Total: 344s
    #301012
  • Pipeline finished with Success
    3 months ago
    Total: 399s
    #304897
  • Pipeline finished with Success
    2 months ago
    #309126
  • Pipeline finished with Success
    2 months ago
    Total: 330s
    #309434
  • Pipeline finished with Success
    23 days ago
    Total: 143s
    #357807
  • Pipeline finished with Success
    23 days ago
    Total: 143s
    #357810
Production build 0.71.5 2024