Problem/Motivation
As of Drupal 8.8.x, it will be possible to override the RenderElement class for LayoutBuilder. This is a good start for being able to change parts of how Layout Builder is rendered, but it is also a little heavy-handed for minor changes. It also requires you to pick only one set of changes and stick to them. That is, if there are 2 modules that override Drupal\layout_builder\Element\LayoutBuilder
, only one of those classes, and therefore only one set of alterations, can be used.
https://www.drupal.org/project/drupal/issues/3143635
✨
Change Layout Preparation into an Event to allow proper alterations
Fixed
was introduced, which allows the ability to affect the preparation of the layout, but this event runs before Administrative sections are built, so it can't be used for alterations to how those Administrative sections are structured.
Ideally, there would be a way to alter the output of Drupal\layout_builder\Element\LayoutBuilder::layout() after the render array has been built and is about to be returned.
Proposed resolution
Implement a new layout alter event in Drupal\layout_builder\Element\LayoutBuilder::layout()
that would allow developers to make alter the render array without having to implement a class override for Drupal\layout_builder\Element\LayoutBuilder
Remaining tasks
- Write a patch containing the new Event.
- Update documentation.
User interface changes
None that I can think of.
API changes
I think a new event being added changes the API, but not sure how this is documented.
Data model changes
None.