You are here

public function LayoutSectionItemList::preSave in Drupal 8

Same name and namespace in other branches
  1. 9 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 a item list class for layout section fields.

Namespace

Drupal\layout_builder\Field

Code

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