$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);
try { /** @var Entity|EntityCollection<Entity>|null $relationData */
$relationData =
$entity->
get($propertyName);
} catch (\InvalidArgumentException
) { continue;
}