Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Serializer.php

function Serializer::__construct

Same name in this branch
  1. 11.1.x vendor/symfony/serializer/Serializer.php \Symfony\Component\Serializer\Serializer::__construct()
  2. 11.1.x vendor/phpdocumentor/reflection-docblock/src/DocBlock/Serializer.php \phpDocumentor\Reflection\DocBlock\Serializer::__construct()
  3. 11.1.x core/modules/rest/src/Plugin/views/style/Serializer.php \Drupal\rest\Plugin\views\style\Serializer::__construct()

Overrides Serializer::__construct

File

core/modules/jsonapi/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 (!str_starts_with(get_class($normalizer), 'Drupal\\jsonapi\\Normalizer')) {
            throw new \LogicException('JSON:API does not allow adding more normalizers!');
        }
    }
    parent::__construct($normalizers, $encoders);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal