Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
CRAP
50.00% covered (danger)
50.00%
1 / 2
JsonEncoder
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
2.50
50.00% covered (danger)
50.00%
1 / 2
 supportsEncoding
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 supportsDecoding
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
/**
 * @file
 * Contains \Drupal\serialization\Encoder\JsonEncoder.
 */
namespace Drupal\serialization\Encoder;
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Encoder\EncoderInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder as BaseJsonEncoder;
/**
 * Adds 'ajax to the supported content types of the JSON encoder'
 */
class JsonEncoder extends BaseJsonEncoder implements EncoderInterface, DecoderInterface {
  /**
   * The formats that this Encoder supports.
   *
   * @var array
   */
  protected static $format = array('json', 'ajax');
  /**
   * {@inheritdoc}
   */
  public function supportsEncoding($format) {
    return in_array($format, static::$format);
  }
  /**
   * {@inheritdoc}
   */
  public function supportsDecoding($format) {
    return in_array($format, static::$format);
  }
}