You are here

class YamlEncoder in Content Synchronization 8.2

Same name and namespace in other branches
  1. 3.0.x 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\EncoderInterface, \Symfony\Component\Serializer\Encoder\DecoderInterface

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 Decodes a string into PHP data.
YamlEncoder::encode public function Encodes data into the given format.
YamlEncoder::supportsDecoding public function Checks whether the deserializer can decode from given format.
YamlEncoder::supportsEncoding public function Checks whether the serializer can encode to given format.
YamlEncoder::__construct public function Constructor.