public static function Section::fromArray in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Section.php \Drupal\layout_builder\Section::fromArray()
- 9 core/modules/layout_builder/src/Section.php \Drupal\layout_builder\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.
- TestSectionList::__construct in core/modules/ layout_builder/ tests/ src/ Kernel/ SectionListTraitTest.php 
- TestSectionList constructor.
File
- core/modules/ layout_builder/ src/ Section.php, line 371 
Class
- Section
- Provides a domain object for layout sections.
Namespace
Drupal\layout_builderCode
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']);
}