YamlSymfony::encode

public static YamlSymfony::encode($data)

Encodes data into the serialization format.

Parameters

mixed $data: The data to encode.

Return value

string The encoded data.

Overrides SerializationInterface::encode

File

core/lib/Drupal/Component/Serialization/YamlSymfony.php, line 17

Class

YamlSymfony
Default serialization for YAML using the Symfony component.

Namespace

Drupal\Component\Serialization

Code

public static function encode($data) {
  try {
    $yaml = new Dumper();
    $yaml->setIndentation(2);
    return $yaml->dump($data, PHP_INT_MAX, 0, TRUE, FALSE);
  }
  catch (\Exception $e) {
    throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
  }
}
doc_Drupal
2016-10-29 09:57:02
Comments
Leave a Comment

Please login to continue.