private function ChainDecoder::getDecoder

Gets the decoder supporting the format.

Parameters

string $format:

Return value

DecoderInterface

Throws

RuntimeException if no decoder is found

1 call to ChainDecoder::getDecoder()
ChainDecoder::supportsDecoding in drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Checks whether the serializer can decode from given format

File

drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainDecoder.php, line 64

Class

ChainDecoder
Decoder delegating the decoding to a chain of decoders.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function getDecoder($format) {
  if (isset($this->decoderByFormat[$format]) && isset($this->decoders[$this->decoderByFormat[$format]])) {
    return $this->decoders[$this->decoderByFormat[$format]];
  }
  foreach ($this->decoders as $i => $decoder) {
    if ($decoder
      ->supportsDecoding($format)) {
      $this->decoderByFormat[$format] = $i;
      return $decoder;
    }
  }
  throw new RuntimeException(sprintf('No decoder found for format "%s".', $format));
}