rex_string::yamlDecode PHP Method

yamlDecode() public static method

Parses YAML into a PHP array.
public static yamlDecode ( string $value ) : array
$value string YAML string
return array
    public static function yamlDecode($value)
    {
        try {
            return Symfony\Component\Yaml\Yaml::parse($value);
        } catch (Symfony\Component\Yaml\Exception\ParseException $exception) {
            throw new rex_yaml_parse_exception($exception->getMessage(), $exception);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Returns the content of a config file.
  *
  * @param string $file    Path to the file
  * @param mixed  $default Default value
  *
  * @return mixed Content of the file or default value if the file isn't readable
  */
 public static function getConfig($file, $default = [])
 {
     $content = self::get($file);
     return $content === null ? $default : rex_string::yamlDecode($content);
 }