public function LayoutSectionItemList::preSave in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::preSave()
Defines custom presave behavior for field values.
This method is called during the process of saving an entity, just before item values are written into storage.
Overrides FieldItemList::preSave
See also
\Drupal\Core\Field\FieldItemInterface::preSave()
File
- core/modules/ layout_builder/ src/ Field/ LayoutSectionItemList.php, line 72 
Class
- LayoutSectionItemList
- Defines an item list class for layout section fields.
Namespace
Drupal\layout_builder\FieldCode
public function preSave() {
  parent::preSave();
  // Loop through each section and reconstruct it to ensure that all default
  // values are present.
  foreach ($this->list as $delta => $item) {
    $item->section = Section::fromArray($item->section
      ->toArray());
  }
}