Problem/Motivation

Currently, EntityWithPluginBagInterface inherits from ConfigEntityInterface, but is not explicitly tied to ConfigEntity, it's just that other entity types haven't used it yet.

Additionally, it assumes an entity class will only have one plugin bag, while modules like Flag already use more than one per entity.

Proposed resolution

Move EntityWithPluginBagInterface into Drupal\Core\Entity, and rename it to EntityWithPluginBagsInterface (plural).
Instead of the entity class magically knowing they have to provide a $pluginConfigKey property, the getPluginBags() method now returns an array of plugin bags, keyed by the property name it uses to store the config.

Remaining tasks

N/A

User interface changes

N/A

API changes

Yes, EntityWithPluginBagInterface is moved to EntityWithPluginBagsInterface and now returns an array of plugin bags instead of a single one.

Original report by @joachim

Comments

tim.plunkett’s picture

Honestly I don't know why EntityWithPluginBagInterface extends from ConfigEntityInterface, I think it could easily extend EntityInterface directly.

I don't know how a non-config entity would use it, but its not a technical limitation.

tim.plunkett’s picture

Title: rename EntityWithPluginBagInterface to ConfigEntityWithPluginBagInterface » Move EntityWithPluginBagInterface out of Drupal\Core\Config\Entity and make it useful for more than one bag
Component: configuration entity system » entity system
Issue summary: View changes
Status: Active » Needs review
Issue tags: +Plugin system

I looked into this issue and noticed one other oversight: it assumes you will only have one plugin bag per entity.

tim.plunkett’s picture

StatusFileSize
new22.63 KB
tim.plunkett’s picture

StatusFileSize
new24.06 KB

@alexpott pointed out I didn't rename the test class or method.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +API clean-up

This is really useful!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

  • Commit 85f243e on 8.x by webchick:
    Issue #2267329 by tim.plunkett | joachim: Move...
tim.plunkett’s picture

Issue tags: +Page Manager

Status: Fixed » Closed (fixed)

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