@@ -138,13 +138,14 @@ private function transformLinkStatus(PropertyMetadata $propertyMetadata, array $
138
138
* - From metadata of the given operation ("collection_operation_name" and "item_operation_name" keys).
139
139
* - From metadata of the current resource.
140
140
*
141
- *
142
141
* @return (string[]|null)[]
143
142
*/
144
143
private function getEffectiveSerializerGroups (array $ options , string $ resourceClass ): array
145
144
{
146
145
if (isset ($ options ['serializer_groups ' ])) {
147
- return [$ options ['serializer_groups ' ], $ options ['serializer_groups ' ]];
146
+ $ groups = (array ) $ options ['serializer_groups ' ];
147
+
148
+ return [$ groups , $ groups ];
148
149
}
149
150
150
151
$ resourceMetadata = $ this ->resourceMetadataFactory ->create ($ resourceClass );
@@ -162,13 +163,15 @@ private function getEffectiveSerializerGroups(array $options, string $resourceCl
162
163
$ denormalizationContext = $ resourceMetadata ->getAttribute ('denormalization_context ' );
163
164
}
164
165
165
- return [$ normalizationContext ['groups ' ] ?? null , $ denormalizationContext ['groups ' ] ?? null ];
166
+ return [
167
+ isset ($ normalizationContext ['groups ' ]) ? (array ) $ normalizationContext ['groups ' ] : null ,
168
+ isset ($ denormalizationContext ['groups ' ]) ? (array ) $ denormalizationContext ['groups ' ] : null ,
169
+ ];
166
170
}
167
171
168
172
/**
169
173
* Gets the serializer groups defined on a property.
170
174
*
171
- *
172
175
* @return string[]
173
176
*/
174
177
private function getPropertySerializerGroups (string $ resourceClass , string $ property ): array
@@ -187,19 +190,17 @@ private function getPropertySerializerGroups(string $resourceClass, string $prop
187
190
/**
188
191
* Gets the serializer groups defined in a resource.
189
192
*
190
- *
191
193
* @return string[]
192
194
*/
193
195
private function getResourceSerializerGroups (string $ resourceClass ): array
194
196
{
195
197
$ serializerClassMetadata = $ this ->serializerClassMetadataFactory ->getMetadataFor ($ resourceClass );
196
198
197
199
$ groups = [];
198
-
199
200
foreach ($ serializerClassMetadata ->getAttributesMetadata () as $ serializerAttributeMetadata ) {
200
- $ groups = array_merge ( $ groups , $ serializerAttributeMetadata ->getGroups ());
201
+ $ groups += array_flip ( $ serializerAttributeMetadata ->getGroups ());
201
202
}
202
203
203
- return array_unique ($ groups );
204
+ return array_keys ($ groups );
204
205
}
205
206
}
0 commit comments