From 615573af6065d278eb0a7000fa8afa4c70967bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20G=C3=B3mez=20Morales?= Date: Tue, 30 Oct 2018 12:20:09 +0100 Subject: [PATCH] Fix for field type blocks --- src/Storage/Legacy.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Storage/Legacy.php b/src/Storage/Legacy.php index 81083b3..0d45c30 100644 --- a/src/Storage/Legacy.php +++ b/src/Storage/Legacy.php @@ -113,6 +113,27 @@ private function repeaterHydrate($record, $app) } } } + + /** + *Fix for field type blocks + */ + if (isset($contentType['fields'][$key]) && $contentType['fields'][$key]['type'] === 'block' && $value !== null) { + $originalMapping=[]; + $originalMapping[$key]['fields'] = $contentType['fields'][$key]['fields']; + $originalMapping[$key]['type'] = 'block'; + $mapping = $app['storage.metadata']->getRepeaterMapping($originalMapping); + $record[$key] = new RepeatingFieldCollection($app['storage'], $mapping); + foreach ($value as $group => $block) { + foreach ($block as $blockName => $fields) { + $fields = $fields; + array_shift($fields); + if (is_array($fields)) { + $record[$key]->addFromArray($fields, $group, null, $blockName); + } + } + } + } + if (isset($contentType['fields'][$key]) && $contentType['fields'][$key]['type'] === 'repeater' && $value !== null) { /** * Hackish fix until #5533 gets fixed, after that the