@@ -79,7 +79,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
79
79
$ fetchPartial = $ this ->shouldOperationFetchPartial ($ resourceClass , $ options );
80
80
$ serializerContext = $ this ->getSerializerContext ($ resourceClass , 'normalization_context ' , $ options );
81
81
82
- $ groups = $ this ->getSerializerGroups ($ options , $ serializerContext );
82
+ $ groups = $ this ->getPropertyMetadataOptions ($ options , $ serializerContext );
83
83
84
84
$ this ->joinRelations ($ queryBuilder , $ queryNameGenerator , $ resourceClass , $ forceEager , $ fetchPartial , $ queryBuilder ->getRootAliases ()[0 ], $ groups , $ serializerContext );
85
85
}
@@ -99,9 +99,9 @@ public function applyToItem(QueryBuilder $queryBuilder, QueryNameGeneratorInterf
99
99
$ fetchPartial = $ this ->shouldOperationFetchPartial ($ resourceClass , $ options );
100
100
$ contextType = isset ($ context ['api_denormalize ' ]) ? 'denormalization_context ' : 'normalization_context ' ;
101
101
$ serializerContext = $ this ->getSerializerContext ($ context ['resource_class ' ] ?? $ resourceClass , $ contextType , $ options );
102
- $ groups = $ this ->getSerializerGroups ($ options , $ serializerContext );
102
+ $ serializerOptions = $ this ->getPropertyMetadataOptions ($ options , $ serializerContext );
103
103
104
- $ this ->joinRelations ($ queryBuilder , $ queryNameGenerator , $ resourceClass , $ forceEager , $ fetchPartial , $ queryBuilder ->getRootAliases ()[0 ], $ groups , $ serializerContext );
104
+ $ this ->joinRelations ($ queryBuilder , $ queryNameGenerator , $ resourceClass , $ forceEager , $ fetchPartial , $ queryBuilder ->getRootAliases ()[0 ], $ serializerOptions , $ serializerContext );
105
105
}
106
106
107
107
/**
@@ -145,6 +145,7 @@ private function joinRelations(QueryBuilder $queryBuilder, QueryNameGeneratorInt
145
145
continue ;
146
146
}
147
147
148
+ $ attributes = $ serializerContext [AbstractNormalizer::ATTRIBUTES ] ?? null ;
148
149
if ((false === $ propertyMetadata ->isReadableLink () || false === $ propertyMetadata ->isReadable ()) && false === $ propertyMetadata ->getAttribute ('fetchEager ' , false )) {
149
150
continue ;
150
151
}
@@ -261,12 +262,12 @@ private function getSerializerContext(string $resourceClass, string $contextType
261
262
*
262
263
* @param array $options represents the operation name so that groups are the one of the specific operation
263
264
*/
264
- private function getSerializerGroups (array $ options , array $ context ): array
265
+ private function getPropertyMetadataOptions (array $ options , array $ context ): array
265
266
{
266
- if (empty ($ context [AbstractNormalizer::GROUPS ])) {
267
- return $ options ;
267
+ if (! empty ($ context [AbstractNormalizer::GROUPS ])) {
268
+ $ options [ ' serializer_groups ' ] = $ context [AbstractNormalizer:: GROUPS ] ;
268
269
}
269
270
270
- return [ ' serializer_groups ' => $ context [AbstractNormalizer:: GROUPS ]] ;
271
+ return $ options ;
271
272
}
272
273
}
0 commit comments