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, and rewritedisableLayoutBuilder()
so that when it is calledsetOverridable(FALSE)
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