You are here

public function Serializer::__construct in JSON:API 8.2

File

src/Serializer/Serializer.php, line 35

Class

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

Namespace

Drupal\jsonapi\Serializer

Code

public function __construct(array $normalizers = [], array $encoders = []) {
  foreach ($normalizers as $normalizer) {
    if (strpos(get_class($normalizer), 'Drupal\\jsonapi\\Normalizer') !== 0) {
      throw new \LogicException('JSON:API does not allow adding more normalizers!');
    }
  }
  parent::__construct($normalizers, $encoders);
}