You are here

public static function Yaml::encode in Drupal 10

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

11 calls to Yaml::encode()
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.
ExtensionListTest::setupTestExtensionList in core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php
Sets up an a test extension list.
FrontMatterTest::createFrontMatterSource in core/tests/Drupal/Tests/Component/FrontMatter/FrontMatterTest.php
Creates a front matter source string.
GenerateTheme::execute in core/lib/Drupal/Core/Command/GenerateTheme.php

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