mirror of
https://github.com/getgrav/grav.git
synced 2026-07-06 17:48:32 +02:00
Fixed flex-options@ in blueprints duplicating items in array
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* Fixed broken Twig try tag when catch has not been defined or is empty
|
||||
* Fixed `FlexForm` serialization
|
||||
* Fixed form validation for numeric values in PHP 8
|
||||
* Fixed `flex-options@` in blueprints duplicating items in array
|
||||
|
||||
# v1.7.18
|
||||
## 07/19/2021
|
||||
|
||||
@@ -831,7 +831,7 @@ class FlexDirectory implements FlexDirectoryInterface
|
||||
* @param array $call
|
||||
* @return void
|
||||
*/
|
||||
protected function dynamicFlexField(array &$field, $property, array $call)
|
||||
protected function dynamicFlexField(array &$field, $property, array $call): void
|
||||
{
|
||||
$params = (array)$call['params'];
|
||||
$object = $call['object'] ?? null;
|
||||
@@ -840,11 +840,28 @@ class FlexDirectory implements FlexDirectoryInterface
|
||||
if ($object && method_exists($object, $method)) {
|
||||
$value = $object->{$method}(...$params);
|
||||
if (is_array($value) && isset($field[$property]) && is_array($field[$property])) {
|
||||
$field[$property] = array_merge_recursive($field[$property], $value);
|
||||
$value = $this->mergeArrays($field[$property], $value);
|
||||
}
|
||||
$field[$property] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array1
|
||||
* @param array $array2
|
||||
* @return array
|
||||
*/
|
||||
protected function mergeArrays(array $array1, array $array2): array
|
||||
{
|
||||
foreach ($array2 as $key => $value) {
|
||||
if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) {
|
||||
$array1[$key] = $this->mergeArrays($array1[$key], $value);
|
||||
} else {
|
||||
$field[$property] = $value;
|
||||
$array1[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $array1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user