blob: 5272f352f5ed7d243170460d46944f20936c408d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace Drupal\Core\Discovery;
use Drupal\Component\Discovery\YamlDiscovery as ComponentYamlDiscovery;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\Serialization\Yaml;
/**
* Provides discovery for YAML files within a given set of directories.
*
* This overrides the Component file decoding with the Core YAML implementation.
*/
class YamlDiscovery extends ComponentYamlDiscovery {
/**
* {@inheritdoc}
*/
protected function decode($file) {
try {
return Yaml::decode(file_get_contents($file)) ?: [];
}
catch (InvalidDataTypeException $e) {
throw new InvalidDataTypeException($file . ': ' . $e->getMessage(), $e->getCode(), $e);
}
}
}
|