Provide output alter event for layout builder

Created on 11 September 2019, over 5 years ago
Updated 30 January 2023, almost 2 years ago

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.

Feature request
Status

Needs work

Version

10.1

Component
Layout builder 

Last updated 2 days ago

Created by

🇺🇸United States pyrello

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Production build 0.71.5 2024