Skip to content

Commit

Permalink
fix(resolveConfig): arrays of fields work now without showing a notic…
Browse files Browse the repository at this point in the history
…e in ACF call

still missing tests and refactoring
  • Loading branch information
Doğa Gürdal committed Dec 3, 2016
1 parent 377758b commit 6b3ab5e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ACFComposer/ResolveConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ public static function forFieldGroup($config) {

$keySuffix = $output['name'];
$output['key'] = "group_{$keySuffix}";
$output['fields'] = array_map(function ($field) use ($keySuffix) {
return self::forField($field, [$keySuffix]);
}, $output['fields']);
$output['fields'] = array_reduce($config['fields'], function ($carry, $fieldConfig) use ($keySuffix) {
$fields = self::forField($fieldConfig, [$keySuffix]);
if (!self::isAssoc($fields)) {
foreach ($fields as $field) {
array_push($carry, $field);
}
} else {
array_push($carry, $fields);
}
return $carry;
}, []);
$output['location'] = array_map('self::mapLocation', $output['location']);
return $output;
}
Expand All @@ -31,6 +39,7 @@ public static function forLayout($config, $parentKeys = []) {

protected static function forEntity($config, $requiredAttributes, $parentKeys = []) {
if (is_string($config)) {
// TODO catch unapplied filters and show warning, then get out of this function to prevent exceptions
$config = apply_filters($config, null);
}
if (!self::isAssoc($config)) {
Expand Down

0 comments on commit 6b3ab5e

Please sign in to comment.