function YamlDiscovery::decode

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

Overrides YamlDiscovery::decode

File

core/lib/Drupal/Core/Discovery/YamlDiscovery.php, line 19

Class

YamlDiscovery
Provides discovery for YAML files within a given set of directories.

Namespace

Drupal\Core\Discovery

Code

protected function decode($file) {
    try {
        return Yaml::decode(file_get_contents($file)) ?: [];
    } catch (InvalidDataTypeException $e) {
        throw new InvalidDataTypeException($file . ': ' . $e->getMessage(), $e->getCode(), $e);
    }
}

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