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