You are here

protected function SerializerDecorator::lazilyInitialize in JSON:API Extras 8.3

Lazily initializes the fallback serializer for the JSON:API serializer.

Breaks circular dependency.

1 call to SerializerDecorator::lazilyInitialize()
SerializerDecorator::relay in src/SerializerDecorator.php
Relays a method call to the decorated service.

File

src/SerializerDecorator.php, line 46

Class

SerializerDecorator
A decorated JSON:API serializer, with lazily initialized fallback serializer.

Namespace

Drupal\jsonapi_extras

Code

protected function lazilyInitialize() {
  if (!$this->isInitialized) {
    $core_serializer = \Drupal::service('serializer');
    $this->decoratedSerializer
      ->setFallbackNormalizer($core_serializer);
    $this->isInitialized = TRUE;
  }
}