diff core/modules/layout_builder/src/Section.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children 129ea1e6d783
line wrap: on
line diff
--- a/core/modules/layout_builder/src/Section.php	Thu Apr 26 11:26:54 2018 +0100
+++ b/core/modules/layout_builder/src/Section.php	Tue Jul 10 15:07:59 2018 +0100
@@ -322,8 +322,7 @@
   /**
    * Returns an array representation of the section.
    *
-   * @internal
-   *   This is intended for use by a storage mechanism for sections.
+   * Only use this method if you are implementing custom storage for sections.
    *
    * @return array
    *   An array representation of the section component.
@@ -338,4 +337,23 @@
     ];
   }
 
+  /**
+   * Creates an object from an array representation of the section.
+   *
+   * Only use this method if you are implementing custom storage for sections.
+   *
+   * @param array $section
+   *   An array of section data in the format returned by ::toArray().
+   *
+   * @return static
+   *   The section object.
+   */
+  public static function fromArray(array $section) {
+    return new static(
+      $section['layout_id'],
+      $section['layout_settings'],
+      array_map([SectionComponent::class, 'fromArray'], $section['components'])
+    );
+  }
+
 }