src/JsonApi/Serializer/ItemNormalizer.php
private function getRelatedResources($object, ?string $format, array $context, array $relationships): array
    {
        if (!isset($context['api_included'])) {
            return [];
        }

        $included = [];
        foreach ($relationships as $relationshipDataArray) {
            if (!\in_array($relationshipDataArray['name'], $context['api_included'], true)) {
                continue;
            }

            $relationshipName = $relationshipDataArray['name'];
            $relationContext = $context;
            $attributeValue = $this->getAttributeValue($object, $relationshipName, $format, $relationContext);

            if (!$attributeValue) {
                continue;
            }

            // Many to one relationship
            if ('one' === $relationshipDataArray['cardinality']) {
                $included[] = $attributeValue['data'];

                continue;
            }
            // Many to many relationship
            foreach ($attributeValue as $attributeValueElement) {
                if (isset($attributeValueElement['data'])) {
                    $included[] = $attributeValueElement['data'];
                }
            }
        }

        return $included;
    }
private function getRelatedResources($object, ?string $format, array $context, array $relationships): array
    {
        if (!isset($context['api_included'])) {
            return [];
        }

        $included = [];
        foreach ($relationships as $relationshipDataArray) {
            if (!\in_array($relationshipDataArray['name'], $context['api_included'], true)) {
                continue;
            }

            $relationshipName = $relationshipDataArray['name'];
            $relationContext = $context;
            $attributeValue = $this->getAttributeValue($object, $relationshipName, $format, $relationContext);

            if (!$attributeValue) {
                continue;
            }

            // Many to one relationship
            if ('one' === $relationshipDataArray['cardinality']) {
                $included[] = $attributeValue['data'];

                continue;
            }
            // Many to many relationship
            foreach ($attributeValue as $attributeValueElement) {
                if (isset($attributeValueElement['data'])) {
                    $included[] = $attributeValueElement['data'];
                }
            }
        }

        return $included;
    }
private function getRelatedResources ( $ object , ? string $ format , array $ context , array $ relationships ) : array { if ( ! isset ( $ context [ 'api_included' ] ) ) { return [ ] ; } $ included = [ ] ; foreach ( $ relationships as $ relationshipDataArray ) { if ( ! \ in_array ( $ relationshipDataArray [ 'name' ] , $ context [ 'api_included' ] , true ) ) { continue ; } $ relationshipName = $ relationshipDataArray [ 'name' ] ; $ relationContext = $ context ; $ attributeValue = $ this -> getAttributeValue ( $ object , $ relationshipName , $ format , $ relationContext ) ; if ( ! $ attributeValue ) { continue ; } // Many to one relationship if ( 'one' === $ relationshipDataArray [ 'cardinality' ] ) { $ included [ ] = $ attributeValue [ 'data' ] ; continue ; } // Many to many relationship foreach ( $ attributeValue as $ attributeValueElement ) { if ( isset ( $ attributeValueElement [ 'data' ] ) ) { $ included [ ] = $ attributeValueElement [ 'data' ] ; } } } return $ included ; }
Populates included keys.
Populates included keys .