Skip to content

Commit bb83e9a

Browse files
fix(symfony): allow to merge array with string in global defaults (api-platform#7037)
* fix: merge an array and not a string * fix: merge an array only if upperkey is 'Formats' * fix: cs * fix: transform string to array globally Co-authored-by: Antoine Bluchet <[email protected]> --------- Co-authored-by: Antoine Bluchet <[email protected]>
1 parent 8744814 commit bb83e9a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Metadata/Resource/Factory/OperationDefaultsTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ private function addGlobalDefaults(ApiResource|Operation $operation): ApiResourc
6363
$currentValue = $operation->{$getter}();
6464

6565
if (\is_array($currentValue) && $currentValue) {
66+
if (\is_string($value)) {
67+
$value = [$value];
68+
}
69+
6670
$operation = $operation->{'with'.$upperKey}(array_merge($value, $currentValue));
6771
}
6872

0 commit comments

Comments
 (0)