You are here

public function Serializer::normalize in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Serializer/Serializer.php \Drupal\jsonapi\Serializer\Serializer::normalize()

File

src/Serializer/Serializer.php, line 44

Class

Serializer
Overrides the Symfony serializer to cordon off our incompatible normalizers.

Namespace

Drupal\jsonapi\Serializer

Code

public function normalize($data, $format = NULL, array $context = []) {
  if ($this
    ->selfSupportsNormalization($data, $format)) {
    return parent::normalize($data, $format, $context);
  }
  if ($this->fallbackNormalizer
    ->supportsNormalization($data, $format)) {
    return $this->fallbackNormalizer
      ->normalize($data, $format, $context);
  }
  return parent::normalize($data, $format, $context);
}