function YamlSymfony::decode

Same name in other branches
  1. 9 core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::decode()
  2. 8.9.x core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::decode()
  3. 11.x core/lib/Drupal/Component/Serialization/YamlSymfony.php \Drupal\Component\Serialization\YamlSymfony::decode()

Overrides SerializationInterface::decode

5 calls to YamlSymfony::decode()
YamlSymfonyTest::testCustomTagSupport in core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
Tests that YAML custom tags are supported and parsed.
YamlSymfonyTest::testDecode in core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
Tests decoding YAML node anchors.
YamlSymfonyTest::testDecodeObjectSupportDisabled in core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
Ensures that decoding PHP objects does not work in Symfony.
YamlSymfonyTest::testEncodeDecode in core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
Tests encoding and decoding basic data structures.
YamlSymfonyTest::testError in core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
Tests that invalid YAML throws an exception.

File

core/lib/Drupal/Component/Serialization/YamlSymfony.php, line 40

Class

YamlSymfony
Default serialization for YAML using the Symfony component.

Namespace

Drupal\Component\Serialization

Code

public static function decode($raw) {
    @trigger_error('Calling ' . __METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \\Drupal\\Component\\Serialization\\Yaml::decode() instead. See https://www.drupal.org/node/3415489', E_USER_DEPRECATED);
    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, SymfonyYaml::PARSE_EXCEPTION_ON_INVALID_TYPE | SymfonyYaml::PARSE_CUSTOM_TAGS);
    } catch (\Exception $e) {
        throw new InvalidDataTypeException($e->getMessage(), $e->getCode(), $e);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.