function SectionStorageTrait::removeSection

1 call to SectionStorageTrait::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/SectionStorage/SectionStorageTrait.php, line 132

Class

SectionStorageTrait
Provides a trait for storing sections on an object.

Namespace

Drupal\layout_builder\SectionStorage

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.