function Yaml::encode
Overrides SerializationInterface::encode
1 call to Yaml::encode()
- GenerateTheme::execute in core/
lib/ Drupal/ Core/ Command/ GenerateTheme.php - Executes the current command.
File
-
core/
lib/ Drupal/ Component/ Serialization/ Yaml.php, line 18
Class
- Yaml
- Provides a YAML serialization implementation using symfony/yaml.
Namespace
Drupal\Component\SerializationCode
public static function encode($data) {
try {
// Set the indentation to 2 to match Drupal's coding standards.
$yaml = new Dumper(2);
return $yaml->dump($data, PHP_INT_MAX, 0, SymfonyYaml::DUMP_EXCEPTION_ON_INVALID_TYPE | SymfonyYaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
} catch (\Exception $e) {
throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
}
}