You are here

public function Serializer::__construct in Zircon Profile 8

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

File

vendor/symfony/serializer/Serializer.php, line 61

Class

Serializer
Serializer serializes and deserializes data.

Namespace

Symfony\Component\Serializer

Code

public function __construct(array $normalizers = array(), array $encoders = array()) {
  foreach ($normalizers as $normalizer) {
    if ($normalizer instanceof SerializerAwareInterface) {
      $normalizer
        ->setSerializer($this);
    }
  }
  $this->normalizers = $normalizers;
  $decoders = array();
  $realEncoders = array();
  foreach ($encoders as $encoder) {
    if ($encoder instanceof SerializerAwareInterface) {
      $encoder
        ->setSerializer($this);
    }
    if ($encoder instanceof DecoderInterface) {
      $decoders[] = $encoder;
    }
    if ($encoder instanceof EncoderInterface) {
      $realEncoders[] = $encoder;
    }
  }
  $this->encoder = new ChainEncoder($realEncoders);
  $this->decoder = new ChainDecoder($decoders);
}