
Problem/Motivation
ContentEntityInterface
implements RevisionableInterface
, but not all of the RevisionableInterface
support revisions (e.g: taxonomy terms).
Before calling $entity->setNewRevision(FALSE);
we should check if the entity allows revisions or not with $entity->getEntityType()->hasKey('revision')
.
Proposed resolution
a) Add a method RevisionableInterface::isRevisionable()
that hides the implementation detail
or
b) Anyone would assume that objects implementing RevisionableInterface
support revisions. Use it only where is needed, and use a trait if possible instead of having the implementation in ContentEntityBase
.
Remaining tasks
Discuss
User interface changes
None.
API changes
Ideally, API additions only, so eligible for 8.1.0.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#5 | 2671352-2.patch | 571 bytes | penyaskito |
Comments
Comment #3
penyaskitoEven funnier, EntityType defines
isRevisionable()
which has nothing to do with that interface. Could we move that there?Comment #4
penyaskitoComment #5
penyaskitoThis would look like this.
Comment #21
joseph.olstadyes this would be helpful!
Comment #22
joseph.olstadHmm, appears this may have already been done elsewhere.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
Comment #23
joseph.olstadThis already exists.
The simplest way to use it is: