You are here

public static function Yaml::decode in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/Component/Serialization/Yaml.php \Drupal\Component\Serialization\Yaml::decode()

Decodes data from the serialization format.

Parameters

string $raw: The raw data string to decode.

Return value

mixed The decoded data.

Overrides SerializationInterface::decode

2 calls to Yaml::decode()
YamlDiscovery::findAll in lib/Drupal/Component/Discovery/YamlDiscovery.php
Returns an array of discoverable items.
YamlFileLoader::loadFile in lib/Drupal/Core/DependencyInjection/YamlFileLoader.php
Loads a YAML file.

File

lib/Drupal/Component/Serialization/Yaml.php, line 36
Contains \Drupal\Component\Serialization\Yaml.

Class

Yaml
Default serialization for YAML using the Symfony component.

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, TRUE, FALSE);
  } catch (\Exception $e) {
    throw new InvalidDataTypeException($e
      ->getMessage(), $e
      ->getCode(), $e);
  }
}