Problem/Motivation
\Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay
has methods supporting the two checkboxes on "Manage display":
"Use Layout Builder": isLayoutBuilderEnabled()
/enableLayoutBuilder()
/disableLayoutBuilder()
"Allow each @entity_type to have its layout customized.": isOverridable()
/setOverridable($overridable = TRUE)
(Ignore the strangeness of one checkbox having 3 methods and the other having 2 with one taking a bool)
In the UI, the "customized" (overridable) checkbox cannot be checked unless Layout Builder is enabled.
However, that is not enforced on the API level.
Proposed resolution
There are multiple options:
- Throw an exception if
isLayoutBuilderEnabled()
is FALSE whensetOverridable()
is called with TRUE or ifdisableLayoutBuilder()
is called whenisOverridable()
is TRUE - Rewrite
setOverridable()
so that when it is called with TRUEenableLayoutBuilder()
is called
#1 is more explicit but may be considered an API break
Remaining tasks
Write tests
Decide on an solution
User interface changes
N/A, this already is enforced in the UI and has test coverage
API changes
Maybe?
Data model changes
N/A
Release notes snippet
N/A
Comments
Comment #3
tim.plunkettComment #4
tim.plunkettComment #5
nord102Comment #6
nord102I have created a patch that implements Proposed Solution - #2 which does the following:
setOverridable
is called with TRUE and Layout Builder is not already enabled,enableLayoutBuilder()
is calledNoting here: the second piece of Proposed Solution - #2 was previously completed.
I have added a test as well
Comment #7
nord102Comment #9
tim.plunkettLooks great, thanks!
Comment #10
alexpottThe issue summary says...
Is the second half of that incorrect?
If so feel free to update the issue summary and set back to "reviewed and tested by the community"
Comment #11
tim.plunkettThat second part was already done in HEAD
Comment #12
alexpottCommitted and pushed 7ca5921520 to 8.8.x and d950a4dbda to 8.7.x. Thanks!
As a bugfix backported to 8.7.x - thanks for making layout builder have less bugs before its stable release.
Fix coding standards on commit.