Active
Project:
Advanced Varnish
Version:
4.0.9
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Jun 2024 at 09:55 UTC
Updated:
12 Mar 2026 at 12:13 UTC
Jump to comment: Most recent
It's not possible to add ESI for blocks in layout builder.
Enable layout builder on node bundle and add a block to this layout. No ESI options can be selected.
Add ESI support for layout builder blocks.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
shumer commentedThat's a whole new feature here :)
Thanks working on that and raising a PR!
The overall approach is solid. The architecture makes sense: event subscriber on section_component.build.render_array, form alter for LB block forms, settings stored in SectionComponent, shared form definition service, and a dedicated controller with composite block ID. These are the right integration points.
However, there are several issues that need to be addressed before this can be merged.
Performance concern:
-
ESILayoutBuilderBlockController::content()renders the entire entity view (getViewBuilder()->view($entity, $viewMode)) and then manually calls pre_render and iterates all sections/regions just to find one component by UUID. This is very heavy for an ESI subrequest that should be fast.Fragile code:
-
$view['#pre_render'][0][0]->{$view['#pre_render'][0][1]}($view)is hardcoded array indices into #pre_render. This will break if any module adds or reorders pre_render callbacks.-
$this->requestStack->pop() / push(): manipulating the request stack is risky and can cause issues with other subscribers.Missing:
- No tests (unit or functional).
- Missing docblocks on several classes.
Edge cases not handled:
- Layout Builder per-entity overrides (entity-level layouts store sections differently from default display).
- LB preview mode, in this case blocks should NOT be replaced with ESI tags during preview.