function YamlSymfony::encode
Same name in other branches
- 9 core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::encode()
- 8.9.x 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
3 calls to YamlSymfony::encode()
- 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::testEncodeObjectSupportDisabled 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 25
Class
- YamlSymfony
- Default serialization for YAML using the Symfony component.
Namespace
Drupal\Component\SerializationCode
public static function encode($data) {
@trigger_error('Calling ' . __METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \\Drupal\\Component\\Serialization\\Yaml::encode() instead. See https://www.drupal.org/node/3415489', E_USER_DEPRECATED);
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.