@@ -139,9 +139,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
139
139
// Never remove this, with `application/json` we don't use our AbstractCollectionNormalizer and we need
140
140
// to remove the collection operation from our context or we'll introduce security issues
141
141
if (isset ($ context ['operation ' ]) && $ context ['operation ' ] instanceof CollectionOperationInterface) {
142
- unset($ context ['operation_name ' ]);
143
- unset($ context ['operation ' ]);
144
- unset($ context ['iri ' ]);
142
+ unset($ context ['operation_name ' ], $ context ['operation ' ], $ context ['iri ' ]);
145
143
}
146
144
147
145
if ($ this ->resourceClassResolver ->isResourceClass ($ resourceClass )) {
@@ -174,8 +172,7 @@ public function normalize(mixed $object, ?string $format = null, array $context
174
172
$ data = parent ::normalize ($ object , $ format , $ context );
175
173
176
174
$ context ['data ' ] = $ data ;
177
- unset($ context ['property_metadata ' ]);
178
- unset($ context ['api_attribute ' ]);
175
+ unset($ context ['property_metadata ' ], $ context ['api_attribute ' ]);
179
176
180
177
if ($ emptyResourceAsIri && \is_array ($ data ) && 0 === \count ($ data )) {
181
178
$ context ['data ' ] = $ iri ;
@@ -758,6 +755,7 @@ protected function getAttributeValue(object $object, string $attribute, ?string
758
755
unset(
759
756
$ context ['resource_class ' ],
760
757
$ context ['force_resource_class ' ],
758
+ $ context ['uri_variables ' ],
761
759
);
762
760
763
761
// Anonymous resources
@@ -788,8 +786,11 @@ protected function getAttributeValue(object $object, string $attribute, ?string
788
786
throw new LogicException (sprintf ('The injected serializer must be an instance of "%s". ' , NormalizerInterface::class));
789
787
}
790
788
791
- unset($ context ['resource_class ' ]);
792
- unset($ context ['force_resource_class ' ]);
789
+ unset(
790
+ $ context ['resource_class ' ],
791
+ $ context ['force_resource_class ' ],
792
+ $ context ['uri_variables ' ]
793
+ );
793
794
794
795
$ attributeValue = $ this ->propertyAccessor ->getValue ($ object , $ attribute );
795
796
@@ -847,8 +848,7 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel
847
848
$ context ['iri ' ] = $ iri = $ this ->iriConverter ->getIriFromResource (resource: $ relatedObject , context: $ context );
848
849
$ context ['data ' ] = $ iri ;
849
850
$ context ['object ' ] = $ relatedObject ;
850
- unset($ context ['property_metadata ' ]);
851
- unset($ context ['api_attribute ' ]);
851
+ unset($ context ['property_metadata ' ], $ context ['api_attribute ' ]);
852
852
853
853
if ($ this ->tagCollector ) {
854
854
$ this ->tagCollector ->collect ($ context );
@@ -906,6 +906,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
906
906
) {
907
907
$ resourceClass = $ this ->resourceClassResolver ->getResourceClass (null , $ className );
908
908
$ context ['resource_class ' ] = $ resourceClass ;
909
+ unset($ context ['uri_variables ' ]);
909
910
910
911
return $ this ->denormalizeCollection ($ attribute , $ propertyMetadata , $ type , $ resourceClass , $ value , $ format , $ context );
911
912
}
@@ -930,7 +931,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
930
931
throw new LogicException (sprintf ('The injected serializer must be an instance of "%s". ' , DenormalizerInterface::class));
931
932
}
932
933
933
- unset($ context ['resource_class ' ]);
934
+ unset($ context ['resource_class ' ], $ context [ ' uri_variables ' ] );
934
935
935
936
return $ this ->serializer ->denormalize ($ value , $ className .'[] ' , $ format , $ context );
936
937
}
@@ -940,7 +941,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
940
941
throw new LogicException (sprintf ('The injected serializer must be an instance of "%s". ' , DenormalizerInterface::class));
941
942
}
942
943
943
- unset($ context ['resource_class ' ]);
944
+ unset($ context ['resource_class ' ], $ context [ ' uri_variables ' ] );
944
945
945
946
return $ this ->serializer ->denormalize ($ value , $ className , $ format , $ context );
946
947
}
0 commit comments