function YamlPecl::encode
Encodes data into the serialization format.
Parameters
mixed $data: The data to encode.
Return value
string The encoded data.
Overrides SerializationInterface::encode
5 calls to YamlPecl::encode()
- YamlPeclTest::testEncode in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlPeclTest.php  - Tests our encode settings.
 - YamlPeclTest::testEncodeDecode in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlPeclTest.php  - Tests encoding and decoding basic data structures.
 - YamlPeclTest::testObjectSupportDisabled in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlPeclTest.php  - Ensures that php object support is disabled.
 - YamlTest::testObjectSupportDisabledPecl in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlTest.php  - Ensures that decoding php objects does not work in PECL.
 - YamlTest::testObjectSupportDisabledSymfony in core/
tests/ Drupal/ Tests/ Component/ Serialization/ YamlTest.php  - Ensures that decoding php objects does not work in Symfony.
 
File
- 
              core/
lib/ Drupal/ Component/ Serialization/ YamlPecl.php, line 15  
Class
- YamlPecl
 - Provides default serialization for YAML using the PECL extension.
 
Namespace
Drupal\Component\SerializationCode
public static function encode($data) {
  static $init;
  if (!isset($init)) {
    ini_set('yaml.output_indent', 2);
    // Do not break lines at 80 characters.
    ini_set('yaml.output_width', -1);
    $init = TRUE;
  }
  return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.