Problem/Motivation
Layout Builder currently has a hard dependency on the layout_onecol layout defined in the Layout Discovery module.
If somebody removes this Layout (plugin) via hook_layout_alter() all hell breaks loose.
This is the case if you only want to support only your own Layouts, and not the Layouts provided by Core.
There is a workaround by using hook_plugin_filter_TYPE__CONSUMER_alter(), but this is a cosmetic workaround.
Proposed resolution
Remove the dependency by removing the hard coded value and allow changing the default value somehow.
Remaining tasks
- Agree on solution
- Write patch
- Write documentation
- Write change record
User interface changes
None
API changes
Data model changes
None
Comments
Comment #2
tim.plunkettWorking on this
Comment #3
tim.plunkettWith update path tests.
Comment #4
tim.plunkettIdk that this needs a UI in core, but one could be written from contrib.
Comment #5
dmsmidtWow this was so quick! Awesome, thanks!
Manual tested:
Ok, automatically a section with layout_onecol is set. (Offtopic: This is by design, although strange one can't have a page without sections
Not ok, I expect at least a warning that no Layouts are available. When turning LB on for Page: PluginNotFoundException.
Ok, update fails gracefully with error messages ("No layout plugins available").
Ok, first defined custom Layout is used by default, jay!
Not ok, see 2
++ updates for experimental
Nit: I like my exceptions with a "." at the end of a sentence.
I'm learning new things here, cool. But can't we return an empty value without calling array_intersect_key?
This search can be a bit stricter. Failed can be anything that crept up.
I agree that we don't need a UI for this in core. It can easily be set via settings.php, an update hook or changing config ymls. This is only relevant for more advanced scenarios. It should be documented somewhere though.
Comment #6
tim.plunkettAha, yeah this does need accounting for during install. Thanks for the thorough review!
1) :)
2) I am quite the opposite, since by default exception messages get concatenated into a larger sentence!
3) Hah, I wrestled with this a bunch. Feel like I'm being too tricky here. Probably should change this
4) Yeah I wasn't sure the best way to check this, I c/p'd this from another test.
5) Yep, NW for that
Comment #7
tim.plunkettNot personally working on this right now, hopefully I'll have time next week.
Comment #8
tim.plunkett#3030647: Do not add a section when editing an empty layout, or differentiate between new layouts and existing empty layouts removes one of the main usages of the onecol layout.
Here's a straight reroll of the old patch.
Comment #11
tim.plunkettRerolled.
Comment #13
johnwebdev commentedThe layout is now called layout_twocol_section. Also updated the update hook name.
Comment #14
tim.plunkettLooks good still, need someone to review!
Comment #15
sam152 commentedI wonder if here we should add 'layout_onecol' as the default when the setting doesn't exist. It would maintain the existing functionality where sites somehow failed to install the settings, deleted it or were between updates somehow.
Other than that, LGTM.
Comment #17
tim.plunkettNW for #15
Comment #18
dhirendra.mishra commentedComment #19
dhirendra.mishra commentedNot uploading Interdiff..Not sure why it was showing wrong changes. However done the fix mentioned in #15 and re-rolled against 8.9.x
Comment #20
tim.plunkettThanks!
Comment #21
alexpottThis needs to use an 8.8.x update file and I think given we're adding an update function this should target 8.9.x
This makes me realise that we've introduced a dependency on config entities from the simple config. If you delete the default layout then the config is invalid.
I ponder if we should do this in a different way. Can we have a default flag on the config entity instead?
Comment #22
rithesh bk commentedcurrently working on it .......
Comment #23
rithesh bk commentedPlease find the updated patch .......