src/Serializer/AbstractItemNormalizer.php
protected function normalizeRelation(PropertyMetadata $propertyMetadata, $relatedObject, string $resourceClass, ?string $format, array $context)
    {
        if (null === $relatedObject || !empty($context['attributes']) || $propertyMetadata->isReadableLink()) {
            if (null === $relatedObject) {
                unset($context['resource_class']);
            } else {
                $context['resource_class'] = $resourceClass;
            }

            if (!$this->serializer instanceof NormalizerInterface) {
                throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class));
            }

            return $this->serializer->normalize($relatedObject, $format, $context);
        }

        $iri = $this->iriConverter->getIriFromItem($relatedObject);
        if (isset($context['resources'])) {
            $context['resources'][$iri] = $iri;
        }
        if (isset($context['resources_to_push']) && $propertyMetadata->getAttribute('push', false)) {
            $context['resources_to_push'][$iri] = $iri;
        }

        return $iri;
    }
protected function normalizeRelation(PropertyMetadata $propertyMetadata, $relatedObject, string $resourceClass, ?string $format, array $context)
    {
        if (null === $relatedObject || !empty($context['attributes']) || $propertyMetadata->isReadableLink()) {
            if (null === $relatedObject) {
                unset($context['resource_class']);
            } else {
                $context['resource_class'] = $resourceClass;
            }

            if (!$this->serializer instanceof NormalizerInterface) {
                throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class));
            }

            return $this->serializer->normalize($relatedObject, $format, $context);
        }

        $iri = $this->iriConverter->getIriFromItem($relatedObject);
        if (isset($context['resources'])) {
            $context['resources'][$iri] = $iri;
        }
        if (isset($context['resources_to_push']) && $propertyMetadata->getAttribute('push', false)) {
            $context['resources_to_push'][$iri] = $iri;
        }

        return $iri;
    }
protected function normalizeRelation ( PropertyMetadata $ propertyMetadata , $ relatedObject , string $ resourceClass , ? string $ format , array $ context ) { if ( null === $ relatedObject || ! empty ( $ context [ 'attributes' ] ) || $ propertyMetadata -> isReadableLink ( ) ) { if ( null === $ relatedObject ) { unset ( $ context [ 'resource_class' ] ) ; } else { $ context [ 'resource_class' ] = $ resourceClass ; } if ( ! $ this -> serializer instanceof NormalizerInterface ) { throw new LogicException ( sprintf ( 'The injected serializer must be an instance of "%s".' , NormalizerInterface :: class ) ) ; } return $ this -> serializer -> normalize ( $ relatedObject , $ format , $ context ) ; } $ iri = $ this -> iriConverter -> getIriFromItem ( $ relatedObject ) ; if ( isset ( $ context [ 'resources' ] ) ) { $ context [ 'resources' ] [ $ iri ] = $ iri ; } if ( isset ( $ context [ 'resources_to_push' ] ) && $ propertyMetadata -> getAttribute ( 'push' , false ) ) { $ context [ 'resources_to_push' ] [ $ iri ] = $ iri ; } return $ iri ; }
Normalizes a relation as an object if is a Link or as an URI.

@throws LogicException

@return string|array
Normalizes a relation as an object if is a Link or as an URI .