Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / layout_builder / src / SectionComponent.php
index 081d982f054b4dd50a12876a349acca5df6c0fa1..4937f7fbcde669fe61c644c043b2f787877bbdfd 100644 (file)
@@ -292,8 +292,7 @@ class SectionComponent {
   /**
    * Returns an array representation of the section component.
    *
-   * @internal
-   *   This is intended for use by a storage mechanism for section components.
+   * Only use this method if you are implementing custom storage for sections.
    *
    * @return array
    *   An array representation of the section component.
@@ -308,4 +307,24 @@ class SectionComponent {
     ];
   }
 
+  /**
+   * Creates an object from an array representation of the section component.
+   *
+   * Only use this method if you are implementing custom storage for sections.
+   *
+   * @param array $component
+   *   An array of section component data in the format returned by ::toArray().
+   *
+   * @return static
+   *   The section component object.
+   */
+  public static function fromArray(array $component) {
+    return (new static(
+      $component['uuid'],
+      $component['region'],
+      $component['configuration'],
+      $component['additional']
+    ))->setWeight($component['weight']);
+  }
+
 }