class Yaml in Zircon Profile 8
Same name in this branch
- 8 vendor/symfony/yaml/Yaml.php \Symfony\Component\Yaml\Yaml
- 8 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml
Default serialization for YAML using the Symfony component.
Hierarchy
- class \Drupal\Component\Serialization\Yaml implements SerializationInterface
Expanded class hierarchy of Yaml
20 files declare their use of Yaml
- ConfigController.php in core/
modules/ config/ src/ Controller/ ConfigController.php - Contains \Drupal\config\Controller\ConfigController.
- ConfigExportUITest.php in core/
modules/ config/ src/ Tests/ ConfigExportUITest.php - Contains \Drupal\config\Tests\ConfigExportUITest.
- ConfigInstallProfileUnmetDependenciesTest.php in core/
modules/ config/ src/ Tests/ ConfigInstallProfileUnmetDependenciesTest.php - Contains \Drupal\config\Tests\ConfigInstallProfileUnmetDependenciesTest.
- ConfigManager.php in core/
lib/ Drupal/ Core/ Config/ ConfigManager.php - Contains \Drupal\Core\Config\ConfigManager.
- ConfigSingleExportForm.php in core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php - Contains \Drupal\config\Form\ConfigSingleExportForm.
1 string reference to 'Yaml'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses Yaml
File
- core/
lib/ Drupal/ Component/ Serialization/ Yaml.php, line 17 - Contains \Drupal\Component\Serialization\Yaml.
Namespace
Drupal\Component\SerializationView source
class Yaml implements SerializationInterface {
/**
* {@inheritdoc}
*/
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);
}
}
/**
* {@inheritdoc}
*/
public static function decode($raw) {
try {
$yaml = new Parser();
// Make sure we have a single trailing newline. A very simple config like
// 'foo: bar' with no newline will fail to parse otherwise.
return $yaml
->parse($raw, TRUE, FALSE);
} catch (\Exception $e) {
throw new InvalidDataTypeException($e
->getMessage(), $e
->getCode(), $e);
}
}
/**
* {@inheritdoc}
*/
public static function getFileExtension() {
return 'yml';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Yaml:: |
public static | function |
Decodes data from the serialization format. Overrides SerializationInterface:: |
|
Yaml:: |
public static | function |
Encodes data into the serialization format. Overrides SerializationInterface:: |
|
Yaml:: |
public static | function |
Gets the file extension for this serialization format. Overrides SerializationInterface:: |