public static function Yaml::encode in Plug 7
Encodes data into the serialization format.
Parameters
mixed $data: The data to encode.
Return value
string The encoded data.
Overrides SerializationInterface::encode
File
- lib/Drupal/ Component/ Serialization/ Yaml.php, line 22 
- Contains \Drupal\Component\Serialization\Yaml.
Class
- Yaml
- Default serialization for YAML using the Symfony component.
Namespace
Drupal\Component\SerializationCode
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);
  }
}