3333use Symfony \Component \Serializer \Mapping \Factory \ClassMetadataFactoryInterface ;
3434use Symfony \Component \Serializer \NameConverter \NameConverterInterface ;
3535use Symfony \Component \Serializer \Normalizer \AbstractNormalizer ;
36+ use Symfony \Component \Serializer \Normalizer \AbstractObjectNormalizer ;
3637
3738/**
3839 * Converts between objects and array including HAL metadata.
@@ -59,7 +60,6 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName
5960 if (null === $ iri ) {
6061 return null ;
6162 }
62-
6363 return ['_links ' => ['self ' => ['href ' => $ iri ]]];
6464 };
6565
@@ -84,10 +84,6 @@ public function getSupportedTypes($format): array
8484 */
8585 public function normalize (mixed $ object , ?string $ format = null , array $ context = []): array |string |int |float |bool |\ArrayObject |null
8686 {
87- if ($ this ->isHalCircularReference ($ object , $ context )) {
88- return $ this ->handleHalCircularReference ($ object , $ format , $ context );
89- }
90-
9187 $ resourceClass = $ this ->getObjectClass ($ object );
9288 if ($ this ->getOutputClass ($ context )) {
9389 return parent ::normalize ($ object , $ format , $ context );
@@ -248,6 +244,10 @@ private function populateRelation(array $data, object $object, ?string $format,
248244 {
249245 $ class = $ this ->getObjectClass ($ object );
250246
247+ if ($ this ->isHalCircularReference ($ object , $ context )) {
248+ return $ this ->handleHalCircularReference ($ object , $ format , $ context );
249+ }
250+
251251 $ attributesMetadata = \array_key_exists ($ class , $ this ->attributesMetadataCache ) ?
252252 $ this ->attributesMetadataCache [$ class ] :
253253 $ this ->attributesMetadataCache [$ class ] = $ this ->classMetadataFactory ? $ this ->classMetadataFactory ->getMetadataFor ($ class )->getAttributesMetadata () : null ;
0 commit comments