You are here

public function FieldNormalizerValue::rasterizeValue in JSON:API 8

Get the rasterized value.

Return value

mixed The value.

Overrides ValueExtractorInterface::rasterizeValue

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

File

src/Normalizer/Value/FieldNormalizerValue.php, line 77

Class

FieldNormalizerValue
Helps normalize fields in compliance with the JSON API spec.

Namespace

Drupal\jsonapi\Normalizer\Value

Code

public function rasterizeValue() {
  if (empty($this->values)) {
    return NULL;
  }
  if ($this->cardinality == 1) {
    assert(count($this->values) === 1);
    return $this->values[0] instanceof FieldItemNormalizerValue ? $this->values[0]
      ->rasterizeValue() : NULL;
  }
  return array_map(function ($value) {
    return $value instanceof FieldItemNormalizerValue ? $value
      ->rasterizeValue() : NULL;
  }, $this->values);
}