Mercurial > hg > isophonics-drupal-site
diff core/modules/layout_builder/src/SectionComponent.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | 1fec387a4317 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/core/modules/layout_builder/src/SectionComponent.php Thu Apr 26 11:26:54 2018 +0100 +++ b/core/modules/layout_builder/src/SectionComponent.php Tue Jul 10 15:07:59 2018 +0100 @@ -292,8 +292,7 @@ /** * 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 @@ ]; } + /** + * 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']); + } + }