public static function getRelationshipLinks(ResourceObject
$relationship_context, ResourceTypeRelationship
$resource_relationship) { $resource_type =
$relationship_context->
getResourceType();
if ($resource_type->
isInternal() || !
$resource_type->
isLocatable()) { return [];
} $public_field_name =
$resource_relationship->
getPublicName();
$relationship_route_name = Routes::
getRouteName($resource_type, "
$public_field_name.relationship.get"
);
$links =
[ 'self' => Url::
fromRoute($relationship_route_name,
['entity' =>
$relationship_context->
getId()]),
];
if (static::
hasNonInternalResourceType($resource_type->
getRelatableResourceTypesByField($public_field_name))) { $related_route_name = Routes::
getRouteName($resource_type, "
$public_field_name.related"
);
$links['related'
] = Url::
fromRoute($related_route_name,
['entity' =>
$relationship_context->
getId()]);
} if ($resource_type->
isVersionable()) { $version_query_parameter =
[JsonApiSpec::VERSION_QUERY_PARAMETER =>
$relationship_context->
getVersionIdentifier()];
$links['self'
]->
setOption('query',
$version_query_parameter);
if (isset($links['related'
])) { $links['related'
]->
setOption('query',
$version_query_parameter);
} } return $links;
}