Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
RenderableInterface was introduced in #2529560: Expand support for link objects as a way to define "an object which can be rendered by the Render API." Numerous objects throughout core already provide render arrays through methods of inconsistent names. For instance many objects like blocks use the method build()
and others like field formatters use view()
. This inconsistency makes the render system harder to comprehend than it needs to be.
Proposed resolution
- All objects that have a method returning a render array representation of the object should use the method
toRenderable()
(as defined by the renderableInterface) to provide their render array. - Pre-existing methods like
build()
should be marked as deprecated and do nothing but wraptoRenderable()
. This resolution was proposed by Tim Plunkett in #2529560-73: Expand support for link objects
Remaining tasks
- Confirm with catch that this meta issue and the plan within is what he intended by "It probably makes sense to exhaust our use of RenderableInterface first" in #1590150-30: Add ArrayAccess support to drupal_render()
- Determine the strategy for breaking down patches/issues. Options include, one patch per class, one class per module/subsystem, one giant patch.
- Determine if all methods to be replaced must be kept as deprecated functions for the duration of 8.x. For instance
build()
for blocks probably can't be removed until 9.x. But are there any methods returning render arrays that could simply be renamed? - Carry out patches.
User interface changes
None.
API changes
I think BC can easily be maintained here.
Data model changes
None.
Comments
Comment #2
stevectorComment #3
tim.plunkettThanks for opening this! I doubt we'll be making any of these changes in 8.0.x, but I agree we can manage the BC for 8.1.x and on
Comment #4
stevectorComment #5
stevectorI made a sample patch in #2636546: Implement RenderableInterface in VariantInterface