Problem/Motivation
Classes that implement \Drupal\Core\Entity\RevisionableInterface and \Drupal\Core\Entity\TranslatableInterface are not just standalone revisionable or translatable objects, they are also Entity objects since they are in the Drupal\Core\Entity namespace.
Not extending the main interface has the drawback that when a RevisionableInterface or TranslatableInterface type hint is used in a method argument, IDEs can not provide a good developer experience because they don't offer suggestions for generic methods from EntityInterface, like id() or label().
Proposed resolution
Make \Drupal\Core\Entity\RevisionableInterface and \Drupal\Core\Entity\TranslatableInterface extend the generic \Drupal\Core\Entity\EntityInterface.
Same for the storage counterparts and all the other specialized interfaces.
Remaining tasks
Review.
User interface changes
Nope.
API changes
Nope.
Data model changes
Nope.
Release notes snippet
Specialized interfaces such as EntityPublishedInterface now extend \Drupal\Core\Entity\EntityInterface.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | interdiff-6.txt | 2.31 KB | amateescu |
| #6 | 3028319-6.patch | 6.65 KB | amateescu |
| #4 | interdiff-4.txt | 1.96 KB | amateescu |
| #4 | 3028319-4.patch | 4.34 KB | amateescu |
| #2 | 3028319.patch | 2.38 KB | amateescu |
Comments
Comment #2
amateescu commentedThis should do it.
Comment #4
amateescu commentedFixed those unit tests.
Comment #5
hchonovThis sounds like a very reasonable idea. However I think that it would be better to be consistent and cover all the interfaces that are placed unter the namespace
Drupal\Core\Entity- for exampleSynchronizableInterface, EntityChangedInterface ....Comment #6
amateescu commentedGood point, let's do that :)
Comment #7
hchonovThank you! Looks good to me :).
Comment #8
catchAlex Pott asked for feedback on the bc aspects of this.
In theory we're changing the expectations when you implement one of these interfaces.
In practice we only expect these to be implemented on top of EntityInterface, and we have the Entity base class that you're supposed to implement with that, so I think the change is OK - although it should have a change record.
Comment #9
effulgentsia commented+1 to #8. Seems squarely in line with "we reserve the ability to add methods to [interfaces not tagged with @api] in minor releases".
Comment #10
alexpottSo let's get a change record for this.
Comment #11
amateescu commentedHere it is: https://www.drupal.org/node/3029284
Comment #12
alexpottCommitted 5d1589b and pushed to 8.7.x. Thanks!
Comment #14
wim leers4 days to refactor entity interfaces and have it committed. That must be a record. Congrats!
Comment #15
amateescu commentedThanks! It's all about a catchy title :P Jokes aside, here's a doxygen cleanup followup enabled by this patch: #3029405: Clean up documentation and type hints that don't need to mention both EntityInterface and another specialized interface anymore
Comment #16
alexpottI forgot to credit @hchonov - ticking the box now so at least drupal.org is correct.