Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Section.php

function Section::fromArray

Creates an object from an array representation of the section.

Only use this method if you are implementing custom storage for sections.

Parameters

array $section: An array of section data in the format returned by ::toArray().

Return value

static The section object.

2 calls to Section::fromArray()
LayoutSectionItemList::preSave in core/modules/layout_builder/src/Field/LayoutSectionItemList.php
Defines custom presave behavior for field values.
SectionData::setValue in core/modules/layout_builder/src/Plugin/DataType/SectionData.php
Sets the data value.

File

core/modules/layout_builder/src/Section.php, line 377

Class

Section
Provides a domain object for layout sections.

Namespace

Drupal\layout_builder

Code

public static function fromArray(array $section) {
    // Ensure expected array keys are present.
    $section += [
        'layout_id' => '',
        'layout_settings' => [],
        'components' => [],
        'third_party_settings' => [],
    ];
    return new static($section['layout_id'], $section['layout_settings'], array_map([
        SectionComponent::class,
        'fromArray',
    ], $section['components']), $section['third_party_settings']);
}
RSS feed
Powered by Drupal