addIncluded example

$serialized = clone $this->createSerializedEntity($fields$definition$result);
        $serialized->addLink('self', $self);
        $serialized->merge($entity);

        // add included entities         $this->serializeRelationships($fields$serialized$entity$result);

        $this->addExtensions($fields$serialized$entity$result);

        if ($isRelationship) {
            $result->addIncluded($serialized);
        } else {
            $result->addEntity($serialized);
        }
    }

    protected function serializeRelationships(ResponseFields $fields, Record $record, Entity $entity, JsonApiEncodingResult $result): void
    {
        $relationships = $record->getRelationships();

        foreach ($relationships as $propertyName => &$relationship) {
            $relationship['links']['related'] = $record->getLink('self') . '/' . $this->camelCaseToSnailCase($propertyName);

            
Home | Imprint | This part of the site doesn't use cookies.