function Yaml::decode

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

Overrides SerializationInterface::decode

18 calls to Yaml::decode()
ConfigValidationTest::createRecipeWithInvalidDataInFile in core/tests/Drupal/KernelTests/Core/Recipe/ConfigValidationTest.php
Creates a recipe with invalid config data in a particular file.
ContentImportTest::testEntityValidationIsTriggered in core/tests/Drupal/FunctionalTests/DefaultContent/ContentImportTest.php
Tests that the importer validates entities before saving them.
entity-id-argument.php in core/modules/views/tests/fixtures/update/entity-id-argument.php
Test fixture.
ExtensionListTest::setupTestExtensionList in core/tests/Drupal/Tests/Core/Extension/ExtensionListTest.php
Sets up an a test extension list.
Finder::__construct in core/lib/Drupal/Core/DefaultContent/Finder.php

... See full list

1 method overrides Yaml::decode()
Yaml::decode in core/lib/Drupal/Core/Serialization/Yaml.php
Decodes data from the serialization format.

File

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

Class

Yaml
Provides a YAML serialization implementation using symfony/yaml.

Namespace

Drupal\Component\Serialization

Code

public static function decode($raw) {
    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.