private function ChainEncoder::getEncoder

Gets the encoder supporting the format.

Parameters

string $format:

Return value

EncoderInterface

Throws

RuntimeException if no encoder is found

2 calls to ChainEncoder::getEncoder()
ChainEncoder::needsNormalization in drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Checks whether the normalization is needed for the given format.
ChainEncoder::supportsEncoding in drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Checks whether the serializer can encode to given format

File

drupal/core/vendor/symfony/serializer/Symfony/Component/Serializer/Encoder/ChainEncoder.php, line 87

Class

ChainEncoder
Encoder delegating the decoding to a chain of encoders.

Namespace

Symfony\Component\Serializer\Encoder

Code

private function getEncoder($format) {
  if (isset($this->encoderByFormat[$format]) && isset($this->encoders[$this->encoderByFormat[$format]])) {
    return $this->encoders[$this->encoderByFormat[$format]];
  }
  foreach ($this->encoders as $i => $encoder) {
    if ($encoder
      ->supportsEncoding($format)) {
      $this->encoderByFormat[$format] = $i;
      return $encoder;
    }
  }
  throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
}