You are here

public static function Yaml::encode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::encode()

Encodes data into the serialization format.

Parameters

mixed $data: The data to encode.

Return value

string The encoded data.

Overrides SerializationInterface::encode

11 calls to Yaml::encode()
ConfigController::downloadExport in core/modules/config/src/Controller/ConfigController.php
Downloads a tarball of the site configuration.
ConfigInstallProfileUnmetDependenciesTest::setUp in core/modules/config/src/Tests/ConfigInstallProfileUnmetDependenciesTest.php
Sets up a Drupal site for running functional and integration tests.
ConfigManager::diff in core/lib/Drupal/Core/Config/ConfigManager.php
Creates a Diff object using the config data from the two storages.
ConfigSingleExportForm::updateExport in core/modules/config/src/Form/ConfigSingleExportForm.php
Handles switching the export textarea.
ConfigSingleImportExportTest::testExport in core/modules/config/src/Tests/ConfigSingleImportExportTest.php
Tests exporting a single configuration file.

... See full list

File

core/lib/Drupal/Component/Serialization/Yaml.php, line 22
Contains \Drupal\Component\Serialization\Yaml.

Class

Yaml
Default serialization for YAML using the Symfony component.

Namespace

Drupal\Component\Serialization

Code

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);
  }
}