Consider adding a BlockPluginInterface::toRenderArray()

Created on 15 December 2017, about 7 years ago
Updated 17 December 2024, 5 days ago

Problem/Motivation

\Drupal\Core\Block\BlockPluginInterface specifies a ::build() method for each plugin to implement
This is currently only called in one place in core, \Drupal\block\BlockViewBuilder, where it is wrapped in a very specific and helpful render array

This logic is duplicated in every other module that wants to render blocks: Panelizer, Page Manager, Display Suite, and now the new core Layout Builder module.

Proposed resolution

Provide a wrapper method for ::build() called ::toRenderArray(), and move the code currently in BlockViewBuilder into the BlockBase implementation

Remaining tasks

N/A

User interface changes

N/A

API changes

API addition to BlockPluginInterface, but it can all but be assumed that every block extends BlockBase

Data model changes

N/A

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

block.module

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024