X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flayout_builder%2Fsrc%2FSectionComponent.php;fp=web%2Fcore%2Fmodules%2Flayout_builder%2Fsrc%2FSectionComponent.php;h=4937f7fbcde669fe61c644c043b2f787877bbdfd;hp=081d982f054b4dd50a12876a349acca5df6c0fa1;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/layout_builder/src/SectionComponent.php b/web/core/modules/layout_builder/src/SectionComponent.php index 081d982f0..4937f7fbc 100644 --- a/web/core/modules/layout_builder/src/SectionComponent.php +++ b/web/core/modules/layout_builder/src/SectionComponent.php @@ -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']); + } + }