By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.7.x
Issue links:
Description:
When interacting with the Layout Builder API, the main data objects are Sections. They are contained by an implementation of SectionListInterface.
A section list will have no sections in it at two different times:
- When it is first created
- When it has had all existing sections removed from it
There are different workflows that may result from the differences between these two cases.
For example, when a new override is created, the sections from the underlying default are copied over.
But these default sections should not be copied over if a user has purposefully removed them all.
Two new methods have been added:
-
\Drupal\layout_builder\SectionListInterface::removeAllSections():
This removes all sections. Previously, code had to rely onremoveSection(), which took a delta.
Before:while (count($section_list)) { $section_list->removeSection(0); }After:
$section_list->removeAllSections();removeAllSections()has an optional parameter:$set_blank. Passing TRUE will cause the layout to be marked as blank, and therefore overridden. -
\Drupal\layout_builder\OverridesSectionStorageInterface::isOverridden()
Allows the override section storage to indicate if it has an override in place. Checking thecount()of the sections is not the same as there being an override, since an empty override is possible.
Impacts:
Module developers