function YamlSymfony::encode
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::encode()
- 10 core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::encode()
- 11.x core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::encode()
Overrides SerializationInterface::encode
4 calls to YamlSymfony::encode()
- Yaml::encode in core/
lib/ Drupal/ Component/ Serialization/ Yaml.php - Encodes data into the serialization format.
- YamlSymfonyTest::testEncode in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlSymfonyTest.php - Tests our encode settings.
- YamlSymfonyTest::testEncodeDecode in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlSymfonyTest.php - Tests encoding and decoding basic data structures.
- YamlSymfonyTest::testObjectSupportDisabled in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlSymfonyTest.php - Ensures that php object support is disabled.
File
-
core/
lib/ Drupal/ Component/ Serialization/ YamlSymfony.php, line 18
Class
- YamlSymfony
- Default serialization for YAML using the Symfony component.
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.