Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Many times the custom logic introduced by a typed entity ends up being used in a preprocess function for rendering. In order to accommodate this we should introduce some opinionated workflow for rendering typed entities.
Requirements:
- Acknowledge there are more than one ways to render a typed entity.
- Ensure an entity can be interfaced for rendering using drupal's rendering pipeline.
- Allow to render a typed entity manually.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3153900--add-renderers--2.patch | 14.16 KB | e0ipso |
Comments
Comment #2
e0ipsoInitial proposal.
Comment #3
e0ipsoComment #4
hawkeye.twolfWow, this is cool. I think it will really help with separating front-end and back-end business logic.
After a quick review, I have one question/suggestion below but no blockers.
Could we use
WrappedEntityBase::toRenderable()
here (after callingWrappedEntityBase::setViewMode()
)?Comment #5
e0ipsoThanks for the review Hawkeye!
That's a good point you raise. While implementing I got a moment of pause and asked myself: Should renderning an entity change the state of the entity?. For now that's what happens, since (as you already mention) we will need to call
WrappedEntityBase::setViewMode()
.This is why I think that for now might want to let this idea sit and stay vigilant for the need of it.
Comment #7
e0ipso