You are here

class YamlEncoder in Content Synchronization 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Encoder/YamlEncoder.php \Drupal\content_sync\Encoder\YamlEncoder

Class YamlEncoder.

@package Drupal\yaml_serialization

Hierarchy

  • class \Drupal\content_sync\Encoder\YamlEncoder implements \Symfony\Component\Serializer\Encoder\DecoderInterface, \Symfony\Component\Serializer\Encoder\EncoderInterface

Expanded class hierarchy of YamlEncoder

1 string reference to 'YamlEncoder'
content_sync.services.yml in ./content_sync.services.yml
content_sync.services.yml
1 service uses YamlEncoder
yaml_serialization.encoder.yaml in ./content_sync.services.yml
Drupal\content_sync\Encoder\YamlEncoder

File

src/Encoder/YamlEncoder.php, line 16

Namespace

Drupal\content_sync\Encoder
View source
class YamlEncoder implements EncoderInterface, DecoderInterface {

  /**
   * The formats that this Encoder supports.
   *
   * @var string
   */
  protected $format = 'yaml';
  protected $yaml;

  /**
   * Constructor.
   */
  public function __construct(Yaml $yaml) {
    $this->yaml = $yaml;
  }
  public function decode($data, $format, array $context = array()) {
    return $this->yaml
      ->decode($data);
  }
  public function supportsDecoding($format) {
    return $format == $this->format;
  }
  public function encode($data, $format, array $context = array()) {
    return $this->yaml
      ->encode($data);
  }
  public function supportsEncoding($format) {
    return $format == $this->format;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
YamlEncoder::$format protected property The formats that this Encoder supports.
YamlEncoder::$yaml protected property
YamlEncoder::decode public function
YamlEncoder::encode public function
YamlEncoder::supportsDecoding public function
YamlEncoder::supportsEncoding public function
YamlEncoder::__construct public function Constructor.