Problem/Motivation
In
#2942661: Sections should have third-party settings →
, Section
objects were given third-party settings so that contrib could put some data on Sections, presumably to modify how they work.
However, if a contrib module wanted to change how the section was rendered (for example, modifying the regions before they were passed to the layout, ala region styles), it wouldn't be able because there is no event or alter hook in Section::toRenderArray()
in order to do so.
Also, it would make sense to have such an event, because in
#2937799: Allow greater flexibility within SectionComponent::toRenderArray() →
a similar event is being called in SectionComponent::toRenderArray()
.
There's also another aspect which cannot be resolved without the ability of 3rd-party to hook-into the section render array building:
- Block module’s scope is to place blocks.
- Layout Builder module’s scope is to place blocks.
Block placements are decentralised. Each block placement is an config entity. Many modules can work together to place blocks on the same page. In other words a module providing a block placement, shouldn’t know if a different module provides also a placement on the same page or even on the same region.
Layout Builder placements are centralized. All the block placements are living in a single object (e.g. as 3rd-party settings of the entity view display). This means that the underlying object should know that the modules providing the block exists. As an effect, the object providing the block placements has hard dependencies on modules providing the blocks. Third-parties are not able to hook-in by themselves, they should be dependencies of the module that provides the object providing the placements.
Illustrating the issue
A landing page, assembling blocks, built with Layout Builder & Page Manager. Each block is provided by different modules, which are reusable units. This means that some projects might want not to use one or more of the modules that are providing the blocks. This not possible right now as the landing page config will have hard dependencies on the modules providing the blocks. This is possible with the Block module as each module is able to ship their block placements.
Proposed resolution
Call an event in Section::toRenderArray()
allowing contrib modules to modify the $regions
array before it's passed to $layout->build()
.
Remaining tasks
None.
User interface changes
None.
API changes
A new event - details to be determined.
Data model changes
None.
Release notes snippet
Todo.