You are here

public static function Yaml::encode in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::encode()
  2. 10 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.

Throws

\Drupal\Component\Serialization\Exception\InvalidDataTypeException

Overrides SerializationInterface::encode

6 calls to Yaml::encode()
DistributionProfileExistingSettingsTest::prepareEnvironment in core/tests/Drupal/FunctionalTests/Installer/DistributionProfileExistingSettingsTest.php
Prepares the current environment for running the test.
ExtensionListTest::setupTestExtensionList in core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php
Sets up an a test extension list.
InstallerExistingConfigTestBase::prepareEnvironment in core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTestBase.php
Prepares the current environment for running the test.
MultipleDistributionsProfileTest::prepareEnvironment in core/tests/Drupal/FunctionalTests/Installer/MultipleDistributionsProfileTest.php
Prepares the current environment for running the test.
UpdateScriptTest::testExtensionCompatibilityChange in core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php
Tests that extension compatibility changes are handled correctly.

... See full list

File

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

Class

Yaml
Provides a YAML serialization implementation.

Namespace

Drupal\Component\Serialization

Code

public static function encode($data) {

  // Instead of using \Drupal\Component\Serialization\Yaml::getSerializer(),
  // always using Symfony for writing the data, to reduce the risk of having
  // differences if different environments (like production and development)
  // do not match in terms of what YAML implementation is available.
  return YamlSymfony::encode($data);
}