function SectionComponent::fromArray

Same name in other branches
  1. 9 core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::fromArray()
  2. 8.9.x core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::fromArray()
  3. 10 core/modules/layout_builder/src/SectionComponent.php \Drupal\layout_builder\SectionComponent::fromArray()

Creates an object from an array representation of the section component.

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

Parameters

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

Return value

static The section component object.

File

core/modules/layout_builder/src/SectionComponent.php, line 311

Class

SectionComponent
Provides a value object for a section component.

Namespace

Drupal\layout_builder

Code

public static function fromArray(array $component) {
    return (new static($component['uuid'], $component['region'], $component['configuration'], $component['additional']))->setWeight($component['weight']);
}

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