Skip to content

Commit

Permalink
Merge pull request #186 from tiito78/master
Browse files Browse the repository at this point in the history
Fix for field type blocks
  • Loading branch information
bobdenotter committed Nov 1, 2018
2 parents 08dcf09 + 615573a commit 3794f36
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Storage/Legacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3794f36

Please sign in to comment.