public function SectionListTrait::removeSection in Drupal 10
Same name and namespace in other branches
- 9 core/modules/layout_builder/src/SectionListTrait.php \Drupal\layout_builder\SectionListTrait::removeSection()
1 call to SectionListTrait::removeSection()
- LayoutBuilderEntityViewDisplay::onDependencyRemoval in core/
modules/ layout_builder/ src/ Entity/ LayoutBuilderEntityViewDisplay.php - Informs the entity that entities it depends on will be deleted.
File
- core/
modules/ layout_builder/ src/ SectionListTrait.php, line 133
Class
- SectionListTrait
- Provides a trait for maintaining a list of sections.
Namespace
Drupal\layout_builderCode
public function removeSection($delta) {
// Clear the section list if there is currently a blank section.
if ($this
->hasBlankSection()) {
$this
->removeAllSections();
}
$sections = $this
->getSections();
unset($sections[$delta]);
$this
->setSections($sections);
// Add a blank section when the last section is removed.
if (empty($sections)) {
$this
->addBlankSection();
}
return $this;
}