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

Breadcrumb

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

function ChainDecoder::getDecoder

Gets the decoder supporting the format.

Throws

RuntimeException if no decoder is found

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

File

vendor/symfony/serializer/Encoder/ChainDecoder.php, line 61

Class

ChainDecoder
Decoder delegating the decoding to a chain of decoders.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function getDecoder(string $format, array $context) : DecoderInterface {
    if (isset($this->decoderByFormat[$format]) && isset($this->decoders[$this->decoderByFormat[$format]])) {
        return $this->decoders[$this->decoderByFormat[$format]];
    }
    $cache = true;
    foreach ($this->decoders as $i => $decoder) {
        $cache = $cache && !$decoder instanceof ContextAwareDecoderInterface;
        if ($decoder->supportsDecoding($format, $context)) {
            if ($cache) {
                $this->decoderByFormat[$format] = $i;
            }
            return $decoder;
        }
    }
    throw new RuntimeException(\sprintf('No decoder found for format "%s".', $format));
}
RSS feed
Powered by Drupal