You are here

public function RelationshipItemNormalizerValue::rasterizeValue in JSON:API 8

Get the rasterized value.

Return value

mixed The value.

Overrides FieldItemNormalizerValue::rasterizeValue

File

src/Normalizer/Value/RelationshipItemNormalizerValue.php, line 59

Class

RelationshipItemNormalizerValue
Helps normalize relationship items in compliance with the JSON API spec.

Namespace

Drupal\jsonapi\Normalizer\Value

Code

public function rasterizeValue() {
  if (!($value = parent::rasterizeValue())) {
    return $value;
  }
  $rasterized_value = [
    'type' => $this->resource
      ->getTypeName(),
    'id' => empty($value['target_uuid']) ? $value : $value['target_uuid'],
  ];
  if (!empty($value['meta'])) {
    $rasterized_value['meta'] = $value['meta'];
  }
  return $rasterized_value;
}