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
Comments
Comment #10
larowlanFeels task-y
Comment #11
wim leersWhat are the consequences of this for Layout Builder? 🤔