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.
By Xano on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0
Issue links:
Description:
Classes can now implement \Drupal\Core\Render\RenderableInterface
to indicate that instances can return renderable representations (render arrays) of themselves. This universal interface should replace any other methods that return render arrays that represent the object on which the method was called.
Example:
class Foo implements RenderableInterface {
/**
* {@inheritdoc}
*/
public function toRenderable() {
return [
'#type' => 'item',
'#title' => $this->getFakeLabel(),
'#markup' => $this->getFakeContent(),
];
}
}
Impacts:
Module developers