Skip to content

Commit 3794f36

Browse files
authored
Merge pull request #186 from tiito78/master
Fix for field type blocks
2 parents 08dcf09 + 615573a commit 3794f36

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Storage/Legacy.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,27 @@ private function repeaterHydrate($record, $app)
113113
}
114114
}
115115
}
116+
117+
/**
118+
*Fix for field type blocks
119+
*/
120+
if (isset($contentType['fields'][$key]) && $contentType['fields'][$key]['type'] === 'block' && $value !== null) {
121+
$originalMapping=[];
122+
$originalMapping[$key]['fields'] = $contentType['fields'][$key]['fields'];
123+
$originalMapping[$key]['type'] = 'block';
124+
$mapping = $app['storage.metadata']->getRepeaterMapping($originalMapping);
125+
$record[$key] = new RepeatingFieldCollection($app['storage'], $mapping);
126+
foreach ($value as $group => $block) {
127+
foreach ($block as $blockName => $fields) {
128+
$fields = $fields;
129+
array_shift($fields);
130+
if (is_array($fields)) {
131+
$record[$key]->addFromArray($fields, $group, null, $blockName);
132+
}
133+
}
134+
}
135+
}
136+
116137
if (isset($contentType['fields'][$key]) && $contentType['fields'][$key]['type'] === 'repeater' && $value !== null) {
117138
/**
118139
* Hackish fix until #5533 gets fixed, after that the

0 commit comments

Comments
 (0)