LayoutBuilderStorage.php in Page Manager 8.4
File
src/Entity/LayoutBuilderStorage.php
View source
<?php
namespace Drupal\page_manager\Entity;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\Entity\EntityInterface;
use Drupal\layout_builder\Section;
class LayoutBuilderStorage extends ConfigEntityStorage {
protected function mapToStorageRecord(EntityInterface $entity) {
$record = parent::mapToStorageRecord($entity);
if (!empty($record['variant_settings']['sections'])) {
$record['variant_settings']['sections'] = array_map(function (Section $section) {
return $section
->toArray();
}, $record['variant_settings']['sections']);
}
return $record;
}
protected function mapFromStorageRecords(array $records) {
foreach ($records as &$record) {
if (!empty($record['variant_settings']['sections'])) {
$sections =& $record['variant_settings']['sections'];
$sections = array_map([
Section::class,
'fromArray',
], $sections);
}
}
return parent::mapFromStorageRecords($records);
}
}