You are here

protected function RelationshipNormalizerValue::getLinks in JSON:API 8

Gets the links for the relationship.

Parameters

string $field_name: The field name for the relationship.

Return value

array An array of links to be rasterized.

1 call to RelationshipNormalizerValue::getLinks()
RelationshipNormalizerValue::rasterizeValue in src/Normalizer/Value/RelationshipNormalizerValue.php
Get the rasterized value.

File

src/Normalizer/Value/RelationshipNormalizerValue.php, line 151

Class

RelationshipNormalizerValue
Helps normalize relationships in compliance with the JSON API spec.

Namespace

Drupal\jsonapi\Normalizer\Value

Code

protected function getLinks($field_name) {
  $route_parameters = [
    'related' => $this->resourceType
      ->getPublicName($field_name),
  ];
  $links['self'] = $this->linkManager
    ->getEntityLink($this->hostEntityId, $this->resourceType, $route_parameters, 'relationship');
  $resource_types = $this->resourceType
    ->getRelatableResourceTypesByField($field_name);
  if (static::hasNonInternalResourceType($resource_types)) {
    $links['related'] = $this->linkManager
      ->getEntityLink($this->hostEntityId, $this->resourceType, $route_parameters, 'related');
  }
  return $links;
}