Provide a reliable way to execute #pre_render while still retaining an array

Created on 19 March 2019, almost 6 years ago
Updated 13 March 2024, 9 months ago

Problem/Motivation

Code like \Drupal\Tests\EntityViewTrait::buildEntityView() attempts to run #pre_render callbacks to simulate rendering, while still leaving it as an array.
\Drupal\Core\Render\Renderer::render() contains the actual logic, but always returns $elements['#markup'] at the end, not $elements.

The logic in ::buildEntityView and elsewhere is not a 1:1 match, which could lead to very unfortunate false positives in tests.

Proposed resolution

Add a method to allow the #type, #lazy_builder, and #pre_render processing while still returning an array

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
RenderΒ  β†’

Last updated 3 days ago

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.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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