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
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | entity-plugin-bag-2267329-4.patch | 24.06 KB | tim.plunkett |
Comments
Comment #1
tim.plunkettHonestly 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.
Comment #2
tim.plunkettI looked into this issue and noticed one other oversight: it assumes you will only have one plugin bag per entity.
Comment #3
tim.plunkettComment #4
tim.plunkett@alexpott pointed out I didn't rename the test class or method.
Comment #5
andypostThis is really useful!
Comment #6
webchickCommitted and pushed to 8.x. Thanks!
Comment #8
tim.plunkett