function Yaml::encode
Same name in other branches
- 9 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::encode()
- 8.9.x core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::encode()
- 10 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::encode()
Overrides SerializationInterface::encode
17 calls to Yaml::encode()
- ConfigConfiguratorTest::testExistingConfigWithKeysInDifferentOrder in core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ ConfigConfiguratorTest.php - ConfigValidationTest::createRecipeWithInvalidDataInFile in core/
tests/ Drupal/ KernelTests/ Core/ Recipe/ ConfigValidationTest.php - Creates a recipe with invalid config data in a particular file.
- ContentImportTest::testEntityValidationIsTriggered in core/
tests/ Drupal/ FunctionalTests/ DefaultContent/ ContentImportTest.php - Tests that the importer validates entities before saving them.
- DependencyTest::testNoVersionInfo in core/
modules/ system/ tests/ src/ Functional/ Module/ DependencyTest.php - Tests visiting admin/modules when a module outside of core has no version.
- DistributionProfileExistingSettingsTest::prepareEnvironment in core/
tests/ Drupal/ FunctionalTests/ Installer/ DistributionProfileExistingSettingsTest.php - Prepares the current environment for running the test.
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.